[PATCH 2/3] conf: Improve parsing of usb-net devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch will allow usb-net devices to be automatically assigned a USB
address (and skip any attempt to assign a PCI one).

Signed-off-by: Rayhan Faizel <rayhan.faizel@xxxxxxxxx>
---
 docs/formatdomain.rst          | 2 +-
 src/conf/domain_conf.c         | 9 ++++++++-
 src/qemu/qemu_domain_address.c | 5 +++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 2adc2ff968..c58ff6a08c 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -5596,7 +5596,7 @@ supported models with these commands:
    qemu-kvm -net nic,model=? /dev/null
 
 Typical values for QEMU and KVM include: ne2k_isa i82551 i82557b i82559er
-ne2k_pci pcnet rtl8139 e1000 virtio. :since:`Since 5.2.0`,
+ne2k_pci pcnet rtl8139 e1000 virtio usb-net. :since:`Since 5.2.0`,
 ``virtio-transitional`` and ``virtio-non-transitional`` values are supported.
 See `Virtio transitional devices`_ for more details.
 :since:`Since 9.3.0` igb is also supported.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 770b5fbbff..c45484c359 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28677,7 +28677,14 @@ virDomainUSBDeviceDefForeach(virDomainDef *def,
         }
     }
 
-    /* TODO: add def->nets here when libvirt starts supporting usb-net */
+    /* usb-net */
+    for (i = 0; i < def->nnets; i++) {
+        virDomainNetDef *net = def->nets[i];
+        if (net->model == VIR_DOMAIN_NET_MODEL_USB_NET) {
+            if (iter(&net->info, opaque) < 0)
+                return -1;
+        }
+    }
 
     /* usb-ccid */
     for (i = 0; i < def->ncontrollers; i++) {
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index cc3bc76971..83f9654fd8 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -2087,6 +2087,11 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def,
     for (i = 0; i < def->nnets; i++) {
         virDomainNetDef *net = def->nets[i];
 
+        /* Skip usb-net device */
+        if (net->model == VIR_DOMAIN_NET_MODEL_USB_NET) {
+            continue;
+        }
+
         /* type='hostdev' network devices might be USB, and are also
          * in hostdevs list anyway, so handle them with other hostdevs
          * instead of here.
-- 
2.34.1
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux