]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Automatically assign address to usb-net device
authorRayhan Faizel <rayhan.faizel@gmail.com>
Tue, 2 Apr 2024 09:18:35 +0000 (14:48 +0530)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Apr 2024 08:40:14 +0000 (10:40 +0200)
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@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/qemu/qemu_domain_address.c

index fc19c1a6f1c8cf37baca8114f89102ef56f9e603..e2f66b982c880b88d0a8e791527307a7dbaa97f1 100644 (file)
@@ -5608,6 +5608,7 @@ ne2k_pci pcnet rtl8139 e1000 virtio. :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.
+:since:`Since 10.3.0` usb-net is supported.
 
 Setting NIC driver-specific options
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index 11a0b0ecda726f83e05df30e333f0f6ee70ac173..48c5d546dacd726b55b3be284f0ebc45f50cc654 100644 (file)
@@ -28695,7 +28695,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++) {
index cc3bc76971d86ae21a6386507bbc9a3ddb45f9e0..7690021ca7cc4b50bc7114b8df40137f1718ffef 100644 (file)
@@ -2087,6 +2087,10 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def,
     for (i = 0; i < def->nnets; i++) {
         virDomainNetDef *net = def->nets[i];
 
+        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.