Re: [PATCH 3/7] qemu: conf: add virQEMUDriverGetDomainCapabilities

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

 





On 4/4/19 8:37 PM, Cole Robinson wrote:
For now it's just a helper for building a qemu virDomainCapsPtr.
It will be used in upcoming patches

It is already being used at qemuConnectGetDomainCapabilities,
making the flow easier to read. Perhaps something worth mentioning
in the commit msg.


Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>



Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
  src/qemu/qemu_conf.c   | 39 +++++++++++++++++++++++++++++++++++++++
  src/qemu/qemu_conf.h   |  7 +++++++
  src/qemu/qemu_driver.c | 18 +++---------------
  3 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 41ce0a978d..635fdcc5a4 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1357,6 +1357,45 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver,
      return ret;
  }
+
+/**
+ * virQEMUDriverGetDomainCapabilities:
+ *
+ * Build a virDomainCapsPtr instance for the passed data.
+ *
+ * Returns: a reference to a virDomainCapsPtr instance or NULL
+ */
+virDomainCapsPtr
+virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
+                                   virQEMUCapsPtr qemuCaps,
+                                   const char *machine,
+                                   virArch arch,
+                                   virDomainVirtType virttype)
+{
+    virDomainCapsPtr ret = NULL, domCaps = NULL;
+    virCapsPtr caps = NULL;
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+
+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
+        goto cleanup;
+
+    if (!(domCaps = virDomainCapsNew(virQEMUCapsGetBinary(qemuCaps), machine,
+                                     arch, virttype)))
+        goto cleanup;
+
+    if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps,
+                                  cfg->firmwares, cfg->nfirmwares) < 0)
+        goto cleanup;
+
+    VIR_STEAL_PTR(ret, domCaps);
+ cleanup:
+    virObjectUnref(domCaps);
+    virObjectUnref(cfg);
+    virObjectUnref(caps);
+    return ret;
+}
+
+
  struct _qemuSharedDeviceEntry {
      size_t ref;
      char **domains; /* array of domain names */
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 14c9d15a72..ddf5ea4b8f 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -331,6 +331,13 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver);
  virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver,
                                          bool refresh);
+virDomainCapsPtr
+virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
+                                   virQEMUCapsPtr qemuCaps,
+                                   const char *machine,
+                                   virArch arch,
+                                   virDomainVirtType virttype);
+
  typedef struct _qemuSharedDeviceEntry qemuSharedDeviceEntry;
  typedef qemuSharedDeviceEntry *qemuSharedDeviceEntryPtr;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7e5bbc3cc9..3e8ae8a4dc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19829,19 +19829,12 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
      virArch arch;
      virDomainVirtType virttype;
      virDomainCapsPtr domCaps = NULL;
-    virQEMUDriverConfigPtr cfg = NULL;
-    virCapsPtr caps = NULL;
virCheckFlags(0, ret); if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0)
          return ret;
- cfg = virQEMUDriverGetConfig(driver);
-
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
      qemuCaps = virQEMUCapsCacheLookupDefault(driver->qemuCapsCache,
                                               emulatorbin,
                                               arch_str,
@@ -19851,18 +19844,13 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
      if (!qemuCaps)
          goto cleanup;
- if (!(domCaps = virDomainCapsNew(virQEMUCapsGetBinary(qemuCaps), machine,
-                                     arch, virttype)))
-        goto cleanup;
-
-    if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps,
-                                  cfg->firmwares, cfg->nfirmwares) < 0)
+    if (!(domCaps = virQEMUDriverGetDomainCapabilities(driver,
+                                                       qemuCaps, machine,
+                                                       arch, virttype)))
          goto cleanup;
ret = virDomainCapsFormat(domCaps);
   cleanup:
-    virObjectUnref(cfg);
-    virObjectUnref(caps);
      virObjectUnref(domCaps);
      virObjectUnref(qemuCaps);
      return ret;

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

  Powered by Linux