virtio-net.c (259a10dbcb4f36a3489fb52f9f7a654761589448) | virtio-net.c (12b2fad7dcc8d08b6a59d1b14caa392ea614c6d9) |
---|---|
1/* 2 * Virtio Network Device 3 * 4 * Copyright IBM, Corp. 2007 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 782 unchanged lines hidden (view full) --- 791static inline uint64_t virtio_net_supported_guest_offloads(VirtIONet *n) 792{ 793 VirtIODevice *vdev = VIRTIO_DEVICE(n); 794 return virtio_net_guest_offloads_by_features(vdev->guest_features); 795} 796 797typedef struct { 798 VirtIONet *n; | 1/* 2 * Virtio Network Device 3 * 4 * Copyright IBM, Corp. 2007 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 782 unchanged lines hidden (view full) --- 791static inline uint64_t virtio_net_supported_guest_offloads(VirtIONet *n) 792{ 793 VirtIODevice *vdev = VIRTIO_DEVICE(n); 794 return virtio_net_guest_offloads_by_features(vdev->guest_features); 795} 796 797typedef struct { 798 VirtIONet *n; |
799 char *id; 800} FailoverId; | 799 DeviceState *dev; 800} FailoverDevice; |
801 802/** | 801 802/** |
803 * Set the id of the failover primary device | 803 * Set the failover primary device |
804 * 805 * @opaque: FailoverId to setup 806 * @opts: opts for device we are handling 807 * @errp: returns an error if this function fails 808 */ | 804 * 805 * @opaque: FailoverId to setup 806 * @opts: opts for device we are handling 807 * @errp: returns an error if this function fails 808 */ |
809static int failover_set_primary(void *opaque, QemuOpts *opts, Error **errp) | 809static int failover_set_primary(DeviceState *dev, void *opaque) |
810{ | 810{ |
811 FailoverId *fid = opaque; 812 const char *standby_id = qemu_opt_get(opts, "failover_pair_id"); | 811 FailoverDevice *fdev = opaque; 812 PCIDevice *pci_dev = (PCIDevice *) 813 object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE); |
813 | 814 |
814 if (g_strcmp0(standby_id, fid->n->netclient_name) == 0) { 815 fid->id = g_strdup(opts->id); | 815 if (!pci_dev) { 816 return 0; 817 } 818 819 if (!g_strcmp0(pci_dev->failover_pair_id, fdev->n->netclient_name)) { 820 fdev->dev = dev; |
816 return 1; 817 } 818 819 return 0; 820} 821 822/** | 821 return 1; 822 } 823 824 return 0; 825} 826 827/** |
823 * Find the primary device id for this failover virtio-net 824 * 825 * @n: VirtIONet device 826 * @errp: returns an error if this function fails 827 */ 828static char *failover_find_primary_device_id(VirtIONet *n) 829{ 830 Error *err = NULL; 831 FailoverId fid; 832 833 fid.n = n; 834 if (!qemu_opts_foreach(qemu_find_opts("device"), 835 failover_set_primary, &fid, &err)) { 836 return NULL; 837 } 838 return fid.id; 839} 840 841/** | |
842 * Find the primary device for this failover virtio-net 843 * 844 * @n: VirtIONet device 845 * @errp: returns an error if this function fails 846 */ 847static DeviceState *failover_find_primary_device(VirtIONet *n) 848{ | 828 * Find the primary device for this failover virtio-net 829 * 830 * @n: VirtIONet device 831 * @errp: returns an error if this function fails 832 */ 833static DeviceState *failover_find_primary_device(VirtIONet *n) 834{ |
849 char *id = failover_find_primary_device_id(n); | 835 FailoverDevice fdev = { 836 .n = n, 837 }; |
850 | 838 |
851 if (!id) { 852 return NULL; 853 } 854 855 return qdev_find_recursive(sysbus_get_default(), id); | 839 qbus_walk_children(sysbus_get_default(), failover_set_primary, NULL, 840 NULL, NULL, &fdev); 841 return fdev.dev; |
856} 857 858static void failover_add_primary(VirtIONet *n, Error **errp) 859{ 860 Error *err = NULL; 861 DeviceState *dev = failover_find_primary_device(n); 862 863 if (dev) { --- 2841 unchanged lines hidden --- | 842} 843 844static void failover_add_primary(VirtIONet *n, Error **errp) 845{ 846 Error *err = NULL; 847 DeviceState *dev = failover_find_primary_device(n); 848 849 if (dev) { --- 2841 unchanged lines hidden --- |