mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +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,18 +375,16 @@ lxcCreateNetDef(const char *type,
|
||||
}
|
||||
|
||||
static virDomainHostdevDef *
|
||||
lxcCreateHostdevDef(int mode, int type, const char *data)
|
||||
lxcCreateHostdevDef(const char *data)
|
||||
{
|
||||
virDomainHostdevDef *hostdev = virDomainHostdevDefNew();
|
||||
|
||||
if (!hostdev)
|
||||
return NULL;
|
||||
|
||||
hostdev->mode = mode;
|
||||
hostdev->source.caps.type = type;
|
||||
|
||||
if (type == VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
|
||||
hostdev->source.caps.u.net.ifname = g_strdup(data);
|
||||
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES;
|
||||
hostdev->source.caps.type = VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET;
|
||||
hostdev->source.caps.u.net.ifname = g_strdup(data);
|
||||
|
||||
return hostdev;
|
||||
}
|
||||
@ -457,9 +455,7 @@ lxcAddNetworkDefinition(virDomainDef *def, lxcNetworkParseData *data)
|
||||
_("Missing 'link' attribute for NIC"));
|
||||
goto error;
|
||||
}
|
||||
if (!(hostdev = lxcCreateHostdevDef(VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
|
||||
VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
|
||||
data->link)))
|
||||
if (!(hostdev = lxcCreateHostdevDef(data->link)))
|
||||
goto error;
|
||||
|
||||
/* This still requires the user to manually setup the vlan interface
|
||||
|
Loading…
x
Reference in New Issue
Block a user