diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2015-02-13 01:43:43 -0500 |
|---|---|---|
| committer | Rusty Russell <rusty@rustcorp.com.au> | 2015-02-13 01:45:53 -0500 |
| commit | 17c56d6de8e809ac57bf4c93d504f5336eb03dd1 (patch) | |
| tree | 3fe674ecd5a2bba8e50f16d692811b223b3c944f | |
| parent | d39a6785f40af658224bc3ff3d4c4a5a2f7c9eda (diff) | |
tools/lguest: give virtqueues names for better error messages
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
| -rw-r--r-- | tools/lguest/lguest.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c index bc444aff2333..70ee62a0eb9a 100644 --- a/tools/lguest/lguest.c +++ b/tools/lguest/lguest.c | |||
| @@ -200,6 +200,9 @@ struct virtqueue { | |||
| 200 | /* Which device owns me. */ | 200 | /* Which device owns me. */ |
| 201 | struct device *dev; | 201 | struct device *dev; |
| 202 | 202 | ||
| 203 | /* Name for printing errors. */ | ||
| 204 | const char *name; | ||
| 205 | |||
| 203 | /* The actual ring of buffers. */ | 206 | /* The actual ring of buffers. */ |
| 204 | struct vring vring; | 207 | struct vring vring; |
| 205 | 208 | ||
| @@ -2366,7 +2369,8 @@ static void emulate_mmio(unsigned long paddr, const u8 *insn) | |||
| 2366 | * routines to allocate and manage them. | 2369 | * routines to allocate and manage them. |
| 2367 | */ | 2370 | */ |
| 2368 | static void add_pci_virtqueue(struct device *dev, | 2371 | static void add_pci_virtqueue(struct device *dev, |
| 2369 | void (*service)(struct virtqueue *)) | 2372 | void (*service)(struct virtqueue *), |
| 2373 | const char *name) | ||
| 2370 | { | 2374 | { |
| 2371 | struct virtqueue **i, *vq = malloc(sizeof(*vq)); | 2375 | struct virtqueue **i, *vq = malloc(sizeof(*vq)); |
| 2372 | 2376 | ||
| @@ -2374,6 +2378,7 @@ static void add_pci_virtqueue(struct device *dev, | |||
| 2374 | vq->next = NULL; | 2378 | vq->next = NULL; |
| 2375 | vq->last_avail_idx = 0; | 2379 | vq->last_avail_idx = 0; |
| 2376 | vq->dev = dev; | 2380 | vq->dev = dev; |
| 2381 | vq->name = name; | ||
| 2377 | 2382 | ||
| 2378 | /* | 2383 | /* |
| 2379 | * This is the routine the service thread will run, and its Process ID | 2384 | * This is the routine the service thread will run, and its Process ID |
| @@ -2666,8 +2671,8 @@ static void setup_console(void) | |||
| 2666 | * stdin. When they put something in the output queue, we write it to | 2671 | * stdin. When they put something in the output queue, we write it to |
| 2667 | * stdout. | 2672 | * stdout. |
| 2668 | */ | 2673 | */ |
| 2669 | add_pci_virtqueue(dev, console_input); | 2674 | add_pci_virtqueue(dev, console_input, "input"); |
| 2670 | add_pci_virtqueue(dev, console_output); | 2675 | add_pci_virtqueue(dev, console_output, "output"); |
| 2671 | 2676 | ||
| 2672 | /* We need a configuration area for the emerg_wr early writes. */ | 2677 | /* We need a configuration area for the emerg_wr early writes. */ |
| 2673 | add_pci_feature(dev, VIRTIO_CONSOLE_F_EMERG_WRITE); | 2678 | add_pci_feature(dev, VIRTIO_CONSOLE_F_EMERG_WRITE); |
| @@ -2838,8 +2843,8 @@ static void setup_tun_net(char *arg) | |||
| 2838 | dev->priv = net_info; | 2843 | dev->priv = net_info; |
| 2839 | 2844 | ||
| 2840 | /* Network devices need a recv and a send queue, just like console. */ | 2845 | /* Network devices need a recv and a send queue, just like console. */ |
| 2841 | add_pci_virtqueue(dev, net_input); | 2846 | add_pci_virtqueue(dev, net_input, "rx"); |
| 2842 | add_pci_virtqueue(dev, net_output); | 2847 | add_pci_virtqueue(dev, net_output, "tx"); |
| 2843 | 2848 | ||
| 2844 | /* | 2849 | /* |
| 2845 | * We need a socket to perform the magic network ioctls to bring up the | 2850 | * We need a socket to perform the magic network ioctls to bring up the |
| @@ -3026,7 +3031,7 @@ static void setup_block_file(const char *filename) | |||
| 3026 | dev = new_pci_device("block", VIRTIO_ID_BLOCK, 0x01, 0x80); | 3031 | dev = new_pci_device("block", VIRTIO_ID_BLOCK, 0x01, 0x80); |
| 3027 | 3032 | ||
| 3028 | /* The device has one virtqueue, where the Guest places requests. */ | 3033 | /* The device has one virtqueue, where the Guest places requests. */ |
| 3029 | add_pci_virtqueue(dev, blk_request); | 3034 | add_pci_virtqueue(dev, blk_request, "request"); |
| 3030 | 3035 | ||
| 3031 | /* Allocate the room for our own bookkeeping */ | 3036 | /* Allocate the room for our own bookkeeping */ |
| 3032 | vblk = dev->priv = malloc(sizeof(*vblk)); | 3037 | vblk = dev->priv = malloc(sizeof(*vblk)); |
| @@ -3107,7 +3112,7 @@ static void setup_rng(void) | |||
| 3107 | dev->priv = rng_info; | 3112 | dev->priv = rng_info; |
| 3108 | 3113 | ||
| 3109 | /* The device has one virtqueue, where the Guest places inbufs. */ | 3114 | /* The device has one virtqueue, where the Guest places inbufs. */ |
| 3110 | add_pci_virtqueue(dev, rng_input); | 3115 | add_pci_virtqueue(dev, rng_input, "input"); |
| 3111 | 3116 | ||
| 3112 | /* We don't have any configuration space */ | 3117 | /* We don't have any configuration space */ |
| 3113 | no_device_config(dev); | 3118 | no_device_config(dev); |
