mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
RPC: Allow HW address in remote_domain_interface struct to be NULL
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>
This commit is contained in:
parent
f9ea3d6011
commit
3640245db7
@ -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]);
|
||||
|
@ -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 */
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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>;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user