]> xenbits.xensource.com Git - libvirt.git/commitdiff
Make qemuBuildHostNetStr() take tapfd as a string
authorMark McLoughlin <markmc@redhat.com>
Wed, 22 Jul 2009 19:17:14 +0000 (20:17 +0100)
committerMark McLoughlin <markmc@redhat.com>
Mon, 27 Jul 2009 14:31:51 +0000 (15:31 +0100)
With hotplug, we're going to want to pass a tapfd name rather than an
actual file descriptor, so prepare the way by passing a string tapfd to
qemuBuildHostNetStr().

* src/qemu_conf.h: qemuBuildHostNetStr() takes a string tapfd now

* src/qemu_conf.c: pass qemuBuildHostNetStr() a string rather than an
  actual file descriptor

* src/qemu_driver.c: update qemudDomainAttachNetDevice() for change

src/qemu_conf.c
src/qemu_conf.h
src/qemu_driver.c

index 0bbaeb1e57e9eaee36b99d259f4f5df2ad006cef..4fe4e399d0d28eebe2c63d47cbb86643d5e479ed 100644 (file)
@@ -1181,13 +1181,13 @@ qemuBuildHostNetStr(virConnectPtr conn,
                     const char *prefix,
                     char type_sep,
                     int vlan,
-                    int tapfd,
+                    const char *tapfd,
                     char **str)
 {
     switch (net->type) {
     case VIR_DOMAIN_NET_TYPE_NETWORK:
     case VIR_DOMAIN_NET_TYPE_BRIDGE:
-        if (virAsprintf(str, "%stap%cfd=%d,vlan=%d%s%s",
+        if (virAsprintf(str, "%stap%cfd=%s,vlan=%d%s%s",
                         prefix ? prefix : "",
                         type_sep, tapfd, vlan,
                         (net->hostnet_name ? ",name=" : ""),
@@ -1805,7 +1805,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
         for (i = 0 ; i < def->nnets ; i++) {
             virDomainNetDefPtr net = def->nets[i];
             char *nic, *host;
-            int tapfd = -1;
+            char *tapfd_name = NULL;
 
             net->vlan = i;
 
@@ -1821,7 +1821,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
             if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
                 net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
-                tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
+                int tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
                 if (tapfd < 0)
                     goto error;
 
@@ -1831,14 +1831,21 @@ int qemudBuildCommandLine(virConnectPtr conn,
                 }
 
                 (*tapfds)[(*ntapfds)++] = tapfd;
+
+                if (virAsprintf(&tapfd_name, "%d", tapfd) < 0)
+                    goto no_memory;
             }
 
             if (qemuBuildHostNetStr(conn, net, NULL, ',',
-                                    net->vlan, tapfd, &host) < 0)
+                                    net->vlan, tapfd_name, &host) < 0) {
+                VIR_FREE(tapfd_name);
                 goto error;
+            }
 
             ADD_ARG_LIT("-net");
             ADD_ARG(host);
+
+            VIR_FREE(tapfd_name);
         }
     }
 
index a68e236d70cc75497036264f32e2520693690e0a..517626ab4078d75a8533e78560f494be5f660675 100644 (file)
@@ -155,7 +155,7 @@ int         qemuBuildHostNetStr         (virConnectPtr conn,
                                          const char *prefix,
                                          char type_sep,
                                          int vlan,
-                                         int tapfd,
+                                         const char *tapfd,
                                          char **str);
 
 int         qemuBuildNicStr             (virConnectPtr conn,
index 54e0f4fd6e53549d5394e7d74c20e28823f11f73..970da14e84c74c191f92ab0fffdea1bc717b44f3 100644 (file)
@@ -4896,7 +4896,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
             net->vlan = vm->def->nets[i]->vlan;
 
     if (qemuBuildHostNetStr(conn, net,
-                            "host_net_add ", ' ', net->vlan, -1, &cmd) < 0)
+                            "host_net_add ", ' ', net->vlan, NULL, &cmd) < 0)
         return -1;
 
     remove_cmd = NULL;