mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-23 06:23:10 +00:00
lxc: Make lxcCreateHostdevDef() less versatile
Usually, we want a function to be as reusable as possible. But in this specific case, when it's used just once we don't need that. The lxcCreateHostdevDef() function is meant to create a hostdev. The first argument selects the hostdev mode (caps/subsys) and the second argument selects the type of hostdev (NET/STORAGE/MISC). But because of how the function is written, it's impossible to create a subsys hostdev as the function sets hostdev->source.caps.type, regardless of mode. So the @mode argument can be dropped. Then, the function is called from one place and one place only. And in there, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET is passed for @type so we can drop that argument too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
452358a1dc
commit
537d90437c
@ -375,17 +375,15 @@ lxcCreateNetDef(const char *type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static virDomainHostdevDef *
|
static virDomainHostdevDef *
|
||||||
lxcCreateHostdevDef(int mode, int type, const char *data)
|
lxcCreateHostdevDef(const char *data)
|
||||||
{
|
{
|
||||||
virDomainHostdevDef *hostdev = virDomainHostdevDefNew();
|
virDomainHostdevDef *hostdev = virDomainHostdevDefNew();
|
||||||
|
|
||||||
if (!hostdev)
|
if (!hostdev)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hostdev->mode = mode;
|
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES;
|
||||||
hostdev->source.caps.type = type;
|
hostdev->source.caps.type = VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET;
|
||||||
|
|
||||||
if (type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
|
|
||||||
hostdev->source.caps.u.net.ifname = g_strdup(data);
|
hostdev->source.caps.u.net.ifname = g_strdup(data);
|
||||||
|
|
||||||
return hostdev;
|
return hostdev;
|
||||||
@ -457,9 +455,7 @@ lxcAddNetworkDefinition(virDomainDef *def, lxcNetworkParseData *data)
|
|||||||
_("Missing 'link' attribute for NIC"));
|
_("Missing 'link' attribute for NIC"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!(hostdev = lxcCreateHostdevDef(VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
|
if (!(hostdev = lxcCreateHostdevDef(data->link)))
|
||||||
VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
|
|
||||||
data->link)))
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* This still requires the user to manually setup the vlan interface
|
/* This still requires the user to manually setup the vlan interface
|
||||||
|
Loading…
Reference in New Issue
Block a user