[PATCH 2/6] Introduce virDomainVirtioSerialAddrAutoAssign again

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

 



This time do not require an address cache as a parameter.

Simplify qemuDomainAttachChrDeviceAssignAddr to not generate
the virtio serial address cache for devices of other types.
---
 src/conf/domain_addr.c   | 21 +++++++++++++++++++++
 src/conf/domain_addr.h   |  6 ++++++
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_hotplug.c  | 11 ++---------
 4 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 065baa7..92a5516 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1167,6 +1167,27 @@ virDomainVirtioSerialAddrAutoAssignFromCache(virDomainDefPtr def,
         return virDomainVirtioSerialAddrAssign(def, addrs, info, allowZero, portOnly);
 }
 
+int
+virDomainVirtioSerialAddrAutoAssign(virDomainDefPtr def,
+                                    virDomainDeviceInfoPtr info,
+                                    bool allowZero)
+{
+    virDomainVirtioSerialAddrSetPtr addrs = NULL;
+    int ret = -1;
+
+    if (!(addrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
+        goto cleanup;
+
+    if (virDomainVirtioSerialAddrAutoAssignFromCache(def, addrs, info, allowZero) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    virDomainVirtioSerialAddrSetFree(addrs);
+    return ret;
+}
+
 
 int
 virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index b0fadc1..141f83b 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -229,6 +229,12 @@ virDomainVirtioSerialAddrAutoAssignFromCache(virDomainDefPtr def,
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
 
 int
+virDomainVirtioSerialAddrAutoAssign(virDomainDefPtr def,
+                                    virDomainDeviceInfoPtr info,
+                                    bool allowZero)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
+int
 virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
                                 virDomainVirtioSerialAddrSetPtr addrs,
                                 virDomainDeviceInfoPtr info,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8bc2584..ce9c4c4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -123,6 +123,7 @@ virDomainUSBAddressSetAddHub;
 virDomainUSBAddressSetCreate;
 virDomainUSBAddressSetFree;
 virDomainVirtioSerialAddrAssign;
+virDomainVirtioSerialAddrAutoAssign;
 virDomainVirtioSerialAddrAutoAssignFromCache;
 virDomainVirtioSerialAddrIsComplete;
 virDomainVirtioSerialAddrRelease;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7bd38ab..cbdcd81 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1641,15 +1641,10 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainDefPtr def,
                                     virDomainChrDefPtr chr)
 {
     int ret = -1;
-    virDomainVirtioSerialAddrSetPtr vioaddrs = NULL;
-
-    if (!(vioaddrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
-        goto cleanup;
 
     if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
         chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
-        if (virDomainVirtioSerialAddrAutoAssignFromCache(NULL, vioaddrs,
-                                                         &chr->info, true) < 0)
+        if (virDomainVirtioSerialAddrAutoAssign(def, &chr->info, true) < 0)
             goto cleanup;
         ret = 1;
 
@@ -1667,8 +1662,7 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainDefPtr def,
 
     } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
                chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
-        if (virDomainVirtioSerialAddrAutoAssignFromCache(NULL, vioaddrs,
-                                                         &chr->info, false) < 0)
+        if (virDomainVirtioSerialAddrAutoAssign(def, &chr->info, false) < 0)
             goto cleanup;
         ret = 1;
     }
@@ -1686,7 +1680,6 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainDefPtr def,
     ret = 0;
 
  cleanup:
-    virDomainVirtioSerialAddrSetFree(vioaddrs);
     return ret;
 }
 
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]