[libvirt PATCH 3/5] Remove all usage of virRun

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

 



Catch the individual usage not removed in previous commits.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/lxc/lxc_driver.c             |  5 +++--
 src/qemu/qemu_domain.c           | 16 ++++++++--------
 src/security/security_apparmor.c | 11 +++--------
 src/util/virnetdev.c             | 24 ++++++++----------------
 4 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 851894c459..61dd35360a 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1423,10 +1423,11 @@ lxcDomainDestroy(virDomainPtr dom)
 
 static int lxcCheckNetNsSupport(void)
 {
-    const char *argv[] = {"ip", "link", "set", "lo", "netns", "-1", NULL};
+    g_autoptr(virCommand) cmd = virCommandNewArgList("ip", "link", "set", "lo",
+                                                     "netns", "-1", NULL);
     int ip_rc;
 
-    if (virRun(argv, &ip_rc) < 0 || ip_rc == 255)
+    if (virCommandRun(cmd, &ip_rc) < 0 || ip_rc == 255)
         return 0;
 
     if (virProcessNamespaceAvailable(VIR_PROCESS_NAMESPACE_NET) < 0)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 98ffd23a71..3d075bca26 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7553,20 +7553,20 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriverPtr driver,
                                   bool try_all,
                                   int ndisks)
 {
-    const char *qemuimgarg[] = { NULL, "snapshot", NULL, NULL, NULL, NULL };
+    const char *qemuimgbin;
     size_t i;
     bool skipped = false;
 
-    qemuimgarg[0] = qemuFindQemuImgBinary(driver);
-    if (qemuimgarg[0] == NULL) {
+    qemuimgbin = qemuFindQemuImgBinary(driver);
+    if (qemuimgbin == NULL) {
         /* qemuFindQemuImgBinary set the error */
         return -1;
     }
 
-    qemuimgarg[2] = op;
-    qemuimgarg[3] = name;
-
     for (i = 0; i < ndisks; i++) {
+        g_autoptr(virCommand) cmd = virCommandNewArgList(qemuimgbin, "snapshot",
+                                                         op, name, NULL);
+
         /* FIXME: we also need to handle LVM here */
         if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
             int format = virDomainDiskGetFormat(def->disks[i]);
@@ -7593,9 +7593,9 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriverPtr driver,
                 return -1;
             }
 
-            qemuimgarg[4] = virDomainDiskGetSource(def->disks[i]);
+            virCommandAddArg(cmd, virDomainDiskGetSource(def->disks[i]));
 
-            if (virRun(qemuimgarg, NULL) < 0) {
+            if (virCommandRun(cmd, NULL) < 0) {
                 if (try_all) {
                     VIR_WARN("skipping snapshot action on %s",
                              def->disks[i]->dst);
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index ca02631f7f..55eb110522 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -203,15 +203,10 @@ load_profile(virSecurityManagerPtr mgr G_GNUC_UNUSED,
 static int
 remove_profile(const char *profile)
 {
-    int rc = -1;
-    const char * const argv[] = {
-        VIRT_AA_HELPER, "-D", "-u", profile, NULL
-    };
+    g_autoptr(virCommand) cmd = virCommandArgList(VIRT_AA_HELPER, "-D", "-u",
+                                                  profile, NULL);
 
-    if (virRun(argv, NULL) == 0)
-        rc = 0;
-
-    return rc;
+    return virCommandRun(cmd, NULL);
 }
 
 static char *
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index dea0bccd57..1d024b8b97 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -508,6 +508,7 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs)
     g_autofree char *pid = NULL;
     g_autofree char *phy = NULL;
     g_autofree char *phy_path = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     int len;
 
     pid = g_strdup_printf("%lld", (long long) pidInNs);
@@ -518,28 +519,19 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs)
 
     if ((len = virFileReadAllQuiet(phy_path, 1024, &phy)) <= 0) {
         /* Not a wireless device. */
-        const char *argv[] = {
-            "ip", "link", "set", ifname, "netns", NULL, NULL
-        };
-
-        argv[5] = pid;
-        if (virRun(argv, NULL) < 0)
-            return -1;
-
+        cmd = virCommandNewArgList("ip", "link",
+                                   "set", ifname, "netns", pid, NULL);
     } else {
-        const char *argv[] = {
-            "iw", "phy", NULL, "set", "netns", NULL, NULL
-        };
-
         /* Remove a line break. */
         phy[len - 1] = '\0';
 
-        argv[2] = phy;
-        argv[5] = pid;
-        if (virRun(argv, NULL) < 0)
-            return -1;
+        cmd = virCommandNewArgList("iw", "phy", phy,
+                                   "set", "netns", pid, NULL);
     }
 
+    if (virCommandRun(cmd, NULL) < 0)
+        return -1;
+
     return 0;
 }
 
-- 
2.25.1





[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