]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
RPC: Allow HW address in remote_domain_interface struct to be NULL
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Mar 2015 16:18:02 +0000 (17:18 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 18 Mar 2015 08:12:36 +0000 (09:12 +0100)
Not all NICs (esp. the virtual ones like TUN) must have a hardware
address. Teach our RPC that it's possible.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
daemon/remote.c
include/libvirt/libvirt-domain.h
src/libvirt-domain.c
src/remote/remote_driver.c
src/remote/remote_protocol.x
src/remote_protocol-structs

index 1dca64a5072fd9d9aa5929c33589c57ed5ed72d0..62a47289909850f09f64cc6aac10246f34612141 100644 (file)
@@ -6525,7 +6525,9 @@ remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces,
         if ((VIR_STRDUP(iface_ret->name, iface->name)) < 0)
             goto cleanup;
 
-        if ((VIR_STRDUP(iface_ret->hwaddr, iface->hwaddr)) < 0)
+        if (iface->hwaddr &&
+            (VIR_ALLOC(iface_ret->hwaddr) < 0 ||
+             VIR_STRDUP(*iface_ret->hwaddr, iface->hwaddr) < 0))
             goto cleanup;
 
         if (iface->naddrs > REMOTE_DOMAIN_IP_ADDR_MAX) {
@@ -6561,7 +6563,10 @@ remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces,
         for (i = 0; i < ifaces_count; i++) {
             remote_domain_interface *iface_ret = &(ret->ifaces.ifaces_val[i]);
             VIR_FREE(iface_ret->name);
-            VIR_FREE(iface_ret->hwaddr);
+            if (iface_ret->hwaddr) {
+                VIR_FREE(*iface_ret->hwaddr);
+                VIR_FREE(iface_ret->hwaddr);
+            }
             for (j = 0; j < iface_ret->addrs.addrs_len; j++) {
                 remote_domain_ip_addr *ip_addr =
                     &(iface_ret->addrs.addrs_val[j]);
index a026b9aa6c1dadf86e829abceda09b9d0bde978f..79ba3d7ab2538968dba3c90fc776b01dad8e9138 100644 (file)
@@ -3760,7 +3760,7 @@ typedef struct _virDomainInterface virDomainInterface;
 typedef virDomainInterface *virDomainInterfacePtr;
 struct _virDomainInterface {
     char *name;                     /* interface name */
-    char *hwaddr;                   /* hardware address */
+    char *hwaddr;                   /* hardware address, may be NULL */
     unsigned int naddrs;            /* number of items in @addrs */
     virDomainIPAddressPtr addrs;    /* array of IP addresses */
 };
index a3f179d9d4bae979d29fc75d1bcefdb34225a43e..0bd9274be8e89e5b9c0fcf54bf312e65162f6cdd 100644 (file)
@@ -11460,7 +11460,8 @@ virDomainFSInfoFree(virDomainFSInfoPtr info)
  *  ... do something with returned values, for example:
  *  for (i = 0; i < ifaces_count; i++) {
  *      printf("name: %s", ifaces[i]->name);
- *      printf(" hwaddr: %s", ifaces[i]->hwaddr);
+ *      if (ifaces[i]->hwaddr)
+ *          printf(" hwaddr: %s", ifaces[i]->hwaddr);
  *
  *      for (j = 0; j < ifaces[i]->naddrs; j++) {
  *          virDomainIPAddressPtr ip_addr = ifaces[i]->addrs + j;
index d89db47ae4fd61ebc564e404401b70b932c1f874..e69f2356f112f181ddace7c3f413379ca1f9fcc0 100644 (file)
@@ -7963,7 +7963,8 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
         if (VIR_STRDUP(iface->name, iface_ret->name) < 0)
             goto cleanup;
 
-        if (VIR_STRDUP(iface->hwaddr, iface_ret->hwaddr) < 0)
+        if (iface_ret->hwaddr &&
+            VIR_STRDUP(iface->hwaddr, *iface_ret->hwaddr) < 0)
             goto cleanup;
 
         if (iface_ret->addrs.addrs_len > REMOTE_DOMAIN_IP_ADDR_MAX) {
index fe5fcdc237ab71124023d2bb2a5191531da829c5..eb862e1a4a6c0c260950c5498e4284abe38cb416 100644 (file)
@@ -3191,7 +3191,7 @@ struct remote_domain_ip_addr {
 
 struct remote_domain_interface {
     remote_nonnull_string name;
-    remote_nonnull_string hwaddr;
+    remote_string hwaddr;
     remote_domain_ip_addr addrs<REMOTE_DOMAIN_IP_ADDR_MAX>;
 };
 
index 5f4ebffba36ef3d5b2d9753b6b58dae3f06eaa5d..b3e2e40d27381e7f30cc1ef63960262595a3b377 100644 (file)
@@ -2646,7 +2646,7 @@ struct remote_domain_ip_addr {
 };
 struct remote_domain_interface {
         remote_nonnull_string      name;
-        remote_nonnull_string      hwaddr;
+        remote_string              hwaddr;
         struct {
                 u_int              addrs_len;
                 remote_domain_ip_addr * addrs_val;