mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
lib: drive_create_data, drive: remove field "iface"
Representing "iface" in the "drive_create_data" and "drive" structures is now useless; the direct backend ignores "iface", while the libvirt one rejects it unless it is empty. Unify both backends -- make them both ignore "iface". (Which only relaxes the libvirt backend, so it cannot cause compatibility problems.) This lets us remove the fields. Update the documentation as well. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1844341 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20220504134155.11832-3-lersek@redhat.com> Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
This commit is contained in:
31
lib/drives.c
31
lib/drives.c
@@ -53,7 +53,6 @@ struct drive_create_data {
|
||||
const char *secret;
|
||||
bool readonly;
|
||||
const char *format;
|
||||
const char *iface;
|
||||
const char *name;
|
||||
const char *disk_label;
|
||||
const char *cachemode;
|
||||
@@ -110,7 +109,6 @@ create_drive_file (guestfs_h *g,
|
||||
drv->src.format = data->format ? safe_strdup (g, data->format) : NULL;
|
||||
|
||||
drv->readonly = data->readonly;
|
||||
drv->iface = data->iface ? safe_strdup (g, data->iface) : NULL;
|
||||
drv->name = data->name ? safe_strdup (g, data->name) : NULL;
|
||||
drv->disk_label = data->disk_label ? safe_strdup (g, data->disk_label) : NULL;
|
||||
drv->cachemode = data->cachemode ? safe_strdup (g, data->cachemode) : NULL;
|
||||
@@ -147,7 +145,6 @@ create_drive_non_file (guestfs_h *g,
|
||||
drv->src.format = data->format ? safe_strdup (g, data->format) : NULL;
|
||||
|
||||
drv->readonly = data->readonly;
|
||||
drv->iface = data->iface ? safe_strdup (g, data->iface) : NULL;
|
||||
drv->name = data->name ? safe_strdup (g, data->name) : NULL;
|
||||
drv->disk_label = data->disk_label ? safe_strdup (g, data->disk_label) : NULL;
|
||||
drv->cachemode = data->cachemode ? safe_strdup (g, data->cachemode) : NULL;
|
||||
@@ -470,7 +467,6 @@ free_drive_struct (struct drive *drv)
|
||||
{
|
||||
free_drive_source (&drv->src);
|
||||
free (drv->overlay);
|
||||
free (drv->iface);
|
||||
free (drv->name);
|
||||
free (drv->disk_label);
|
||||
free (drv->cachemode);
|
||||
@@ -511,14 +507,12 @@ drive_to_string (guestfs_h *g, const struct drive *drv)
|
||||
s_blocksize = safe_asprintf (g, "%d", drv->blocksize);
|
||||
|
||||
return safe_asprintf
|
||||
(g, "%s%s%s%s protocol=%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||
(g, "%s%s%s%s protocol=%s%s%s%s%s%s%s%s%s%s%s",
|
||||
drv->src.u.path,
|
||||
drv->readonly ? " readonly" : "",
|
||||
drv->src.format ? " format=" : "",
|
||||
drv->src.format ? : "",
|
||||
guestfs_int_drive_protocol_to_string (drv->src.protocol),
|
||||
drv->iface ? " iface=" : "",
|
||||
drv->iface ? : "",
|
||||
drv->name ? " name=" : "",
|
||||
drv->name ? : "",
|
||||
drv->disk_label ? " label=" : "",
|
||||
@@ -747,8 +741,6 @@ guestfs_impl_add_drive_opts (guestfs_h *g, const char *filename,
|
||||
? optargs->readonly : false;
|
||||
data.format = optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK
|
||||
? optargs->format : NULL;
|
||||
data.iface = optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_IFACE_BITMASK
|
||||
? optargs->iface : NULL;
|
||||
data.name = optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_NAME_BITMASK
|
||||
? optargs->name : NULL;
|
||||
data.disk_label = optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_LABEL_BITMASK
|
||||
@@ -804,12 +796,6 @@ guestfs_impl_add_drive_opts (guestfs_h *g, const char *filename,
|
||||
free_drive_servers (data.servers, data.nr_servers);
|
||||
return -1;
|
||||
}
|
||||
if (data.iface && !VALID_FORMAT_IFACE (data.iface)) {
|
||||
error (g, _("%s parameter is empty or contains disallowed characters"),
|
||||
"iface");
|
||||
free_drive_servers (data.servers, data.nr_servers);
|
||||
return -1;
|
||||
}
|
||||
if (data.disk_label && !VALID_DISK_LABEL (data.disk_label)) {
|
||||
error (g, _("label parameter is empty, too long, or contains disallowed characters"));
|
||||
free_drive_servers (data.servers, data.nr_servers);
|
||||
@@ -935,24 +921,17 @@ guestfs_impl_add_drive_ro (guestfs_h *g, const char *filename)
|
||||
|
||||
int
|
||||
guestfs_impl_add_drive_with_if (guestfs_h *g, const char *filename,
|
||||
const char *iface)
|
||||
const char *iface ATTRIBUTE_UNUSED)
|
||||
{
|
||||
const struct guestfs_add_drive_opts_argv optargs = {
|
||||
.bitmask = GUESTFS_ADD_DRIVE_OPTS_IFACE_BITMASK,
|
||||
.iface = iface,
|
||||
};
|
||||
|
||||
return guestfs_add_drive_opts_argv (g, filename, &optargs);
|
||||
return guestfs_add_drive_opts_argv (g, filename, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
guestfs_impl_add_drive_ro_with_if (guestfs_h *g, const char *filename,
|
||||
const char *iface)
|
||||
const char *iface ATTRIBUTE_UNUSED)
|
||||
{
|
||||
const struct guestfs_add_drive_opts_argv optargs = {
|
||||
.bitmask = GUESTFS_ADD_DRIVE_OPTS_IFACE_BITMASK
|
||||
| GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK,
|
||||
.iface = iface,
|
||||
.bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK,
|
||||
.readonly = true,
|
||||
};
|
||||
|
||||
|
||||
@@ -298,7 +298,6 @@ struct drive {
|
||||
|
||||
/* Various per-drive flags. */
|
||||
bool readonly;
|
||||
char *iface;
|
||||
char *name;
|
||||
char *disk_label;
|
||||
char *cachemode;
|
||||
|
||||
@@ -1465,12 +1465,6 @@ construct_libvirt_xml_disk (guestfs_h *g,
|
||||
const char *type, *uuid;
|
||||
int r;
|
||||
|
||||
/* XXX We probably could support this if we thought about it some more. */
|
||||
if (drv->iface) {
|
||||
error (g, _("‘iface’ parameter is not supported by the libvirt backend"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
start_element ("disk") {
|
||||
attribute ("device", "disk");
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ guestfs_impl_add_domain (guestfs_h *g, const char *domain_name,
|
||||
int live;
|
||||
int allowuuid;
|
||||
const char *readonlydisk;
|
||||
const char *iface;
|
||||
const char *cachemode;
|
||||
const char *discard;
|
||||
bool copyonread;
|
||||
@@ -78,8 +77,6 @@ guestfs_impl_add_domain (guestfs_h *g, const char *domain_name,
|
||||
? optargs->libvirturi : NULL;
|
||||
readonly = optargs->bitmask & GUESTFS_ADD_DOMAIN_READONLY_BITMASK
|
||||
? optargs->readonly : 0;
|
||||
iface = optargs->bitmask & GUESTFS_ADD_DOMAIN_IFACE_BITMASK
|
||||
? optargs->iface : NULL;
|
||||
live = optargs->bitmask & GUESTFS_ADD_DOMAIN_LIVE_BITMASK
|
||||
? optargs->live : 0;
|
||||
allowuuid = optargs->bitmask & GUESTFS_ADD_DOMAIN_ALLOWUUID_BITMASK
|
||||
@@ -136,10 +133,6 @@ guestfs_impl_add_domain (guestfs_h *g, const char *domain_name,
|
||||
optargs2.bitmask |= GUESTFS_ADD_LIBVIRT_DOM_READONLY_BITMASK;
|
||||
optargs2.readonly = readonly;
|
||||
}
|
||||
if (iface) {
|
||||
optargs2.bitmask |= GUESTFS_ADD_LIBVIRT_DOM_IFACE_BITMASK;
|
||||
optargs2.iface = iface;
|
||||
}
|
||||
if (live) {
|
||||
error (g, _("libguestfs live support was removed in libguestfs 1.48"));
|
||||
goto cleanup;
|
||||
@@ -193,7 +186,6 @@ guestfs_impl_add_libvirt_dom (guestfs_h *g, void *domvp,
|
||||
virDomainPtr dom = domvp;
|
||||
ssize_t r;
|
||||
int readonly;
|
||||
const char *iface;
|
||||
const char *cachemode;
|
||||
const char *discard;
|
||||
bool copyonread;
|
||||
@@ -208,9 +200,6 @@ guestfs_impl_add_libvirt_dom (guestfs_h *g, void *domvp,
|
||||
readonly =
|
||||
optargs->bitmask & GUESTFS_ADD_LIBVIRT_DOM_READONLY_BITMASK
|
||||
? optargs->readonly : 0;
|
||||
iface =
|
||||
optargs->bitmask & GUESTFS_ADD_LIBVIRT_DOM_IFACE_BITMASK
|
||||
? optargs->iface : NULL;
|
||||
live =
|
||||
optargs->bitmask & GUESTFS_ADD_LIBVIRT_DOM_LIVE_BITMASK
|
||||
? optargs->live : 0;
|
||||
@@ -289,10 +278,6 @@ guestfs_impl_add_libvirt_dom (guestfs_h *g, void *domvp,
|
||||
data.optargs.bitmask = 0;
|
||||
data.readonly = readonly;
|
||||
data.readonlydisk = readonlydisk;
|
||||
if (iface) {
|
||||
data.optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_IFACE_BITMASK;
|
||||
data.optargs.iface = iface;
|
||||
}
|
||||
if (cachemode) {
|
||||
data.optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_CACHEMODE_BITMASK;
|
||||
data.optargs.cachemode = cachemode;
|
||||
|
||||
Reference in New Issue
Block a user