libxl: Add support for Virtio disk configuration

This patch adds basic support for configuring and assisting virtio-mmio
based virtio-disk backend (emulator) which is intended to run out of
Qemu and could be run in any domain.
Although the Virtio block device is quite different from traditional
Xen PV block device (vbd) from the toolstack's point of view:
 - as the frontend is virtio-blk which is not a Xenbus driver, nothing
   written to Xenstore are fetched by the frontend currently ("vdev"
   is not passed to the frontend). But this might need to be revised
   in future, so frontend data might be written to Xenstore in order to
   support hotplugging virtio devices or passing the backend domain id
   on arch where the device-tree is not available.
 - the ring-ref/event-channel are not used for the backend<->frontend
   communication, the proposed IPC for Virtio is IOREQ/DM
it is still a "block device" and ought to be integrated in existing
"disk" handling. So, re-use (and adapt) "disk" parsing/configuration
logic to deal with Virtio devices as well.

For the immediate purpose and an ability to extend that support for
other use-cases in future (Qemu, virtio-pci, etc) perform the following
actions:
- Add new disk backend type (LIBXL_DISK_BACKEND_STANDALONE) and reflect
  that in the configuration
- Introduce new disk "specification" and "transport" fields to struct
  libxl_device_disk. Both are written to the Xenstore. The transport
  field is only used for the specification "virtio" and it assumes
  only "mmio" value for now.
- Introduce new "specification" option with "xen" communication
  protocol being default value.
- Add new device kind (LIBXL__DEVICE_KIND_VIRTIO_DISK) as current
  one (LIBXL__DEVICE_KIND_VBD) doesn't fit into Virtio disk model

An example of domain configuration for Virtio disk:
disk = [ 'phy:/dev/mmcblk0p3, xvda1, backendtype=standalone, specification=virtio']

Nothing has changed for default Xen disk configuration.

Please note, this patch is not enough for virtio-disk to work
on Xen (Arm), as for every Virtio device (including disk) we need
to allocate Virtio MMIO params (IRQ and memory region) and pass
them to the backend, also update Guest device-tree. The subsequent
patch will add these missing bits. For the current patch,
the default "irq" and "base" are just written to the Xenstore.
This is not an ideal splitting, but this way we avoid breaking
the bisectability.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Tested-by: Jiamei Xie <jiamei.xie@arm.com>
This commit is contained in:
Oleksandr Tyshchenko authored and Julien Grall committed 2022-07-28 19:25:43 +01:00
1 parent f732240fd3
commit 66dd1c62b2
14 files changed
+768 -450

No files matched your search

+34 -4
View File
@@ -232,7 +232,7 @@ Specifies the backend implementation to use
=item Supported values
phy, qdisk
phy, qdisk, standalone
=item Mandatory
@@ -244,11 +244,13 @@ Automatically determine which backend to use.
=back
This does not affect the guest's view of the device. It controls
which software implementation of the Xen backend driver is used.
It controls which software implementation of the backend driver is used.
Depending on the "specification" option this may affect the guest's view
of the device.
Not all backend drivers support all combinations of other options.
For example, "phy" does not support formats other than "raw".
For example, "phy" and "standalone" do not support formats other than "raw"
and "standalone" does not support specifications other than "virtio".
Normally this option should not be specified, in which case libxl will
automatically determine the most suitable backend.
@@ -373,8 +375,36 @@ processing or causing malfunction to the frontend or the whole domain.
Note frontends can ignore such recommendation.
=item B<specification>=I<SPECIFICATION>
=over 4
=item Description
Specifies the communication protocol (specification) to use for the chosen
"backendtype" option
=item Supported values
xen, virtio
=item Mandatory
No
=item Default value
xen
=back
Besides forcing toolstack to use specific backend implementation, this also
affects the guest's view of the device. For example, "virtio" requires
Virtio frontend driver (virtio-blk) to be used. Please note, the virtual
device (vdev) is not passed to the guest in that case, but it still must be
specified for the internal purposes.
=back
=head1 COLO Parameters
+8
View File
@@ -1763,6 +1763,10 @@ x.DirectIoSafe = bool(xc.direct_io_safe)
if err := x.DiscardEnable.fromC(&xc.discard_enable);err != nil {
return fmt.Errorf("converting field DiscardEnable: %v", err)
}
x.Specification = DiskSpecification(xc.specification)
x.Transport = DiskTransport(xc.transport)
x.Irq = uint32(xc.irq)
x.Base = uint64(xc.base)
if err := x.ColoEnable.fromC(&xc.colo_enable);err != nil {
return fmt.Errorf("converting field ColoEnable: %v", err)
}
@@ -1803,6 +1807,10 @@ xc.direct_io_safe = C.bool(x.DirectIoSafe)
if err := x.DiscardEnable.toC(&xc.discard_enable); err != nil {
return fmt.Errorf("converting field DiscardEnable: %v", err)
}
xc.specification = C.libxl_disk_specification(x.Specification)
xc.transport = C.libxl_disk_transport(x.Transport)
xc.irq = C.uint32_t(x.Irq)
xc.base = C.uint64_t(x.Base)
if err := x.ColoEnable.toC(&xc.colo_enable); err != nil {
return fmt.Errorf("converting field ColoEnable: %v", err)
}
+18
View File
@@ -99,6 +99,20 @@ DiskBackendUnknown DiskBackend = 0
DiskBackendPhy DiskBackend = 1
DiskBackendTap DiskBackend = 2
DiskBackendQdisk DiskBackend = 3
DiskBackendStandalone DiskBackend = 4
)
type DiskSpecification int
const(
DiskSpecificationUnknown DiskSpecification = 0
DiskSpecificationXen DiskSpecification = 1
DiskSpecificationVirtio DiskSpecification = 2
)
type DiskTransport int
const(
DiskTransportUnknown DiskTransport = 0
DiskTransportMmio DiskTransport = 1
)
type NicType int
@@ -645,6 +659,10 @@ Readwrite int
IsCdrom int
DirectIoSafe bool
DiscardEnable Defbool
Specification DiskSpecification
Transport DiskTransport
Irq uint32
Base uint64
ColoEnable Defbool
ColoRestoreEnable Defbool
ColoHost string
+7
View File
@@ -549,6 +549,13 @@
*/
#define LIBXL_HAVE_ASSISTED_APIC 1
/*
* LIBXL_HAVE_DEVICE_DISK_SPECIFICATION indicates that 'specification' and
* 'transport' fields (of libxl_disk_specification and libxl_disk_transport
* types respectively) are present in libxl_device_disk.
*/
#define LIBXL_HAVE_DEVICE_DISK_SPECIFICATION 1
/*
* libxl ABI compatibility
*
+58 -4
View File
@@ -289,9 +289,16 @@ static int disk_try_backend(disk_try_backend_args *a,
libxl_disk_backend backend)
{
libxl__gc *gc = a->gc;
libxl_disk_specification specification = a->disk->specification;
/* returns 0 (ie, DISK_BACKEND_UNKNOWN) on failure, or
* backend on success */
if ((specification == LIBXL_DISK_SPECIFICATION_VIRTIO &&
backend != LIBXL_DISK_BACKEND_STANDALONE) ||
(specification != LIBXL_DISK_SPECIFICATION_VIRTIO &&
backend == LIBXL_DISK_BACKEND_STANDALONE))
goto bad_specification;
switch (backend) {
case LIBXL_DISK_BACKEND_PHY:
if (a->disk->format != LIBXL_DISK_FORMAT_RAW) {
@@ -329,6 +336,29 @@ static int disk_try_backend(disk_try_backend_args *a,
if (a->disk->script) goto bad_script;
return backend;
case LIBXL_DISK_BACKEND_STANDALONE:
if (a->disk->format != LIBXL_DISK_FORMAT_RAW)
goto bad_format;
if (a->disk->script)
goto bad_script;
if (libxl_defbool_val(a->disk->colo_enable))
goto bad_colo;
if (a->disk->backend_domid != LIBXL_TOOLSTACK_DOMID) {
LOG(DEBUG, "Disk vdev=%s, is using a storage driver domain, "
"skipping physical device check", a->disk->vdev);
return backend;
}
if (libxl__try_phy_backend(a->stab.st_mode))
return backend;
LOG(DEBUG, "Disk vdev=%s, backend standalone unsuitable as phys path not a "
"block device", a->disk->vdev);
return 0;
default:
LOG(DEBUG, "Disk vdev=%s, backend %d unknown", a->disk->vdev, backend);
return 0;
@@ -352,6 +382,12 @@ static int disk_try_backend(disk_try_backend_args *a,
LOG(DEBUG, "Disk vdev=%s, backend %s not compatible with colo",
a->disk->vdev, libxl_disk_backend_to_string(backend));
return 0;
bad_specification:
LOG(DEBUG, "Disk vdev=%s, backend %s not compatible with specification %s",
a->disk->vdev, libxl_disk_backend_to_string(backend),
libxl_disk_specification_to_string(specification));
return 0;
}
int libxl__backendpath_parse_domid(libxl__gc *gc, const char *be_path,
@@ -376,8 +412,9 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) {
a.gc = gc;
a.disk = disk;
LOG(DEBUG, "Disk vdev=%s spec.backend=%s", disk->vdev,
libxl_disk_backend_to_string(disk->backend));
LOG(DEBUG, "Disk vdev=%s spec.backend=%s specification=%s", disk->vdev,
libxl_disk_backend_to_string(disk->backend),
libxl_disk_specification_to_string(disk->specification));
if (disk->format == LIBXL_DISK_FORMAT_EMPTY) {
if (!disk->is_cdrom) {
@@ -392,7 +429,8 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) {
}
memset(&a.stab, 0, sizeof(a.stab));
} else if ((disk->backend == LIBXL_DISK_BACKEND_UNKNOWN ||
disk->backend == LIBXL_DISK_BACKEND_PHY) &&
disk->backend == LIBXL_DISK_BACKEND_PHY ||
disk->backend == LIBXL_DISK_BACKEND_STANDALONE) &&
disk->backend_domid == LIBXL_TOOLSTACK_DOMID &&
!disk->script) {
if (stat(disk->pdev_path, &a.stab)) {
@@ -408,7 +446,8 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) {
ok=
disk_try_backend(&a, LIBXL_DISK_BACKEND_PHY) ?:
disk_try_backend(&a, LIBXL_DISK_BACKEND_QDISK) ?:
disk_try_backend(&a, LIBXL_DISK_BACKEND_TAP);
disk_try_backend(&a, LIBXL_DISK_BACKEND_TAP) ?:
disk_try_backend(&a, LIBXL_DISK_BACKEND_STANDALONE);
if (ok)
LOG(DEBUG, "Disk vdev=%s, using backend %s",
disk->vdev,
@@ -441,10 +480,25 @@ char *libxl__device_disk_string_of_backend(libxl_disk_backend backend)
case LIBXL_DISK_BACKEND_QDISK: return "qdisk";
case LIBXL_DISK_BACKEND_TAP: return "phy";
case LIBXL_DISK_BACKEND_PHY: return "phy";
case LIBXL_DISK_BACKEND_STANDALONE: return "standalone";
default: return NULL;
}
}
char *libxl__device_disk_string_of_specification(libxl_disk_specification specification)
{
switch (specification) {
case LIBXL_DISK_SPECIFICATION_XEN: return "xen";
case LIBXL_DISK_SPECIFICATION_VIRTIO: return "virtio";
default: return NULL;
}
}
char *libxl__device_disk_string_of_transport(libxl_disk_transport transport)
{
return (transport == LIBXL_DISK_TRANSPORT_MMIO ? "mmio" : NULL);
}
const char *libxl__qemu_disk_format_string(libxl_disk_format format)
{
switch (format) {
+139 -7
View File
@@ -164,6 +164,30 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,
rc = libxl__resolve_domid(gc, disk->backend_domname, &disk->backend_domid);
if (rc < 0) return rc;
if (disk->specification == LIBXL_DISK_SPECIFICATION_UNKNOWN)
disk->specification = LIBXL_DISK_SPECIFICATION_XEN;
if (disk->specification == LIBXL_DISK_SPECIFICATION_XEN &&
disk->transport != LIBXL_DISK_TRANSPORT_UNKNOWN) {
LOGD(ERROR, domid, "Transport is only supported for specification virtio");
return ERROR_INVAL;
}
/* Force transport mmio for specification virtio for now */
if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
if (!(disk->transport == LIBXL_DISK_TRANSPORT_UNKNOWN ||
disk->transport == LIBXL_DISK_TRANSPORT_MMIO)) {
LOGD(ERROR, domid, "Unsupported transport for specification virtio");
return ERROR_INVAL;
}
disk->transport = LIBXL_DISK_TRANSPORT_MMIO;
}
if (hotplug && disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
LOGD(ERROR, domid, "Hotplug isn't supported for specification virtio");
return ERROR_FAIL;
}
/* Force Qdisk backend for CDROM devices of guests with a device model. */
if (disk->is_cdrom != 0 &&
libxl__domain_type(gc, domid) == LIBXL_DOMAIN_TYPE_HVM) {
@@ -205,6 +229,9 @@ static int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
case LIBXL_DISK_BACKEND_QDISK:
device->backend_kind = LIBXL__DEVICE_KIND_QDISK;
break;
case LIBXL_DISK_BACKEND_STANDALONE:
device->backend_kind = LIBXL__DEVICE_KIND_VIRTIO_DISK;
break;
default:
LOGD(ERROR, domid, "Unrecognized disk backend type: %d",
disk->backend);
@@ -213,7 +240,8 @@ static int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
device->domid = domid;
device->devid = devid;
device->kind = LIBXL__DEVICE_KIND_VBD;
device->kind = disk->backend == LIBXL_DISK_BACKEND_STANDALONE ?
LIBXL__DEVICE_KIND_VIRTIO_DISK : LIBXL__DEVICE_KIND_VBD;
return 0;
}
@@ -331,7 +359,14 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
assert(device->backend_kind == LIBXL__DEVICE_KIND_VBD);
break;
case LIBXL_DISK_BACKEND_STANDALONE:
dev = disk->pdev_path;
flexarray_append(back, "params");
flexarray_append(back, dev);
assert(device->backend_kind == LIBXL__DEVICE_KIND_VIRTIO_DISK);
break;
case LIBXL_DISK_BACKEND_TAP:
LOG(ERROR, "blktap is not supported");
rc = ERROR_FAIL;
@@ -387,6 +422,14 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
flexarray_append_pair(back, "discard-enable",
libxl_defbool_val(disk->discard_enable) ?
"1" : "0");
flexarray_append(back, "specification");
flexarray_append(back, libxl__device_disk_string_of_specification(disk->specification));
if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
flexarray_append(back, "transport");
flexarray_append(back, libxl__device_disk_string_of_transport(disk->transport));
flexarray_append_pair(back, "base", GCSPRINTF("%"PRIu64, disk->base));
flexarray_append_pair(back, "irq", GCSPRINTF("%u", disk->irq));
}
flexarray_append(front, "backend-id");
flexarray_append(front, GCSPRINTF("%d", disk->backend_domid));
@@ -535,6 +578,53 @@ static int libxl__disk_from_xenstore(libxl__gc *gc, const char *libxl_path,
}
libxl_string_to_backend(ctx, tmp, &(disk->backend));
tmp = libxl__xs_read(gc, XBT_NULL,
GCSPRINTF("%s/specification", libxl_path));
if (!tmp) {
LOG(DEBUG, "Missing xenstore node %s/specification, assuming specification xen", libxl_path);
disk->specification = LIBXL_DISK_SPECIFICATION_XEN;
} else {
rc = libxl_disk_specification_from_string(tmp, &disk->specification);
if (rc) {
LOG(ERROR, "Unable to parse xenstore node %s/specification", libxl_path);
goto cleanup;
}
}
if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
tmp = libxl__xs_read(gc, XBT_NULL,
GCSPRINTF("%s/transport", libxl_path));
if (!tmp) {
LOG(ERROR, "Missing xenstore node %s/transport", libxl_path);
goto cleanup;
}
rc = libxl_disk_transport_from_string(tmp, &disk->transport);
if (rc) {
LOG(ERROR, "Unable to parse xenstore node %s/transport", libxl_path);
goto cleanup;
}
if (disk->transport != LIBXL_DISK_TRANSPORT_MMIO) {
LOG(ERROR, "Only transport mmio is expected for specification virtio");
goto cleanup;
}
tmp = libxl__xs_read(gc, XBT_NULL,
GCSPRINTF("%s/base", libxl_path));
if (!tmp) {
LOG(ERROR, "Missing xenstore node %s/base", libxl_path);
goto cleanup;
}
disk->base = strtoul(tmp, NULL, 10);
tmp = libxl__xs_read(gc, XBT_NULL,
GCSPRINTF("%s/irq", libxl_path));
if (!tmp) {
LOG(ERROR, "Missing xenstore node %s/irq", libxl_path);
goto cleanup;
}
disk->irq = strtoul(tmp, NULL, 10);
}
disk->vdev = xs_read(ctx->xsh, XBT_NULL,
GCSPRINTF("%s/dev", libxl_path), &len);
if (!disk->vdev) {
@@ -578,6 +668,42 @@ cleanup:
return rc;
}
static int libxl__device_disk_get_path(libxl__gc *gc, uint32_t domid,
char **path)
{
const char *xen_dir, *virtio_dir;
char *xen_path, *virtio_path;
int rc;
/* default path */
xen_path = GCSPRINTF("%s/device/%s",
libxl__xs_libxl_path(gc, domid),
libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VBD));
rc = libxl__xs_read_checked(gc, XBT_NULL, xen_path, &xen_dir);
if (rc)
return rc;
virtio_path = GCSPRINTF("%s/device/%s",
libxl__xs_libxl_path(gc, domid),
libxl__device_kind_to_string(LIBXL__DEVICE_KIND_VIRTIO_DISK));
rc = libxl__xs_read_checked(gc, XBT_NULL, virtio_path, &virtio_dir);
if (rc)
return rc;
if (xen_dir && virtio_dir) {
LOGD(ERROR, domid, "Invalid configuration, both xen and virtio paths are present");
return ERROR_INVAL;
} else if (virtio_dir) {
*path = virtio_path;
} else {
*path = xen_path;
}
return 0;
}
int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid,
const char *vdev, libxl_device_disk *disk)
{
@@ -591,10 +717,12 @@ int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid,
libxl_device_disk_init(disk);
libxl_path = libxl__domain_device_libxl_path(gc, domid, devid,
LIBXL__DEVICE_KIND_VBD);
rc = libxl__device_disk_get_path(gc, domid, &libxl_path);
if (rc)
return rc;
rc = libxl__disk_from_xenstore(gc, libxl_path, devid, disk);
rc = libxl__disk_from_xenstore(gc, GCSPRINTF("%s/%d", libxl_path, devid),
devid, disk);
GC_FREE;
return rc;
@@ -608,16 +736,19 @@ int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
char *fe_path, *libxl_path;
char *val;
int rc;
libxl__device_kind kind;
diskinfo->backend = NULL;
diskinfo->devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
/* tap devices entries in xenstore are written as vbd devices. */
/* tap devices entries in xenstore are written as vbd/virtio_disk devices. */
kind = disk->backend == LIBXL_DISK_BACKEND_STANDALONE ?
LIBXL__DEVICE_KIND_VIRTIO_DISK : LIBXL__DEVICE_KIND_VBD;
fe_path = libxl__domain_device_frontend_path(gc, domid, diskinfo->devid,
LIBXL__DEVICE_KIND_VBD);
kind);
libxl_path = libxl__domain_device_libxl_path(gc, domid, diskinfo->devid,
LIBXL__DEVICE_KIND_VBD);
kind);
diskinfo->backend = xs_read(ctx->xsh, XBT_NULL,
GCSPRINTF("%s/backend", libxl_path), NULL);
if (!diskinfo->backend) {
@@ -1421,6 +1552,7 @@ LIBXL_DEFINE_DEVICE_LIST(disk)
#define libxl__device_disk_update_devid NULL
DEFINE_DEVICE_TYPE_STRUCT(disk, VBD, disks,
.get_path = libxl__device_disk_get_path,
.merge = libxl_device_disk_merge,
.dm_needed = libxl_device_disk_dm_needed,
.from_xenstore = (device_from_xenstore_fn_t)libxl__disk_from_xenstore,
+2
View File
@@ -1493,6 +1493,8 @@ _hidden char * libxl__domain_pvcontrol_read(libxl__gc *gc,
/* from xl_device */
_hidden char *libxl__device_disk_string_of_backend(libxl_disk_backend backend);
_hidden char *libxl__device_disk_string_of_specification(libxl_disk_specification specification);
_hidden char *libxl__device_disk_string_of_transport(libxl_disk_transport transport);
_hidden char *libxl__device_disk_string_of_format(libxl_disk_format format);
_hidden const char *libxl__qemu_disk_format_string(libxl_disk_format format);
_hidden int libxl__device_disk_set_backend(libxl__gc*, libxl_device_disk*);
+18
View File
@@ -130,6 +130,18 @@ libxl_disk_backend = Enumeration("disk_backend", [
(1, "PHY"),
(2, "TAP"),
(3, "QDISK"),
(4, "STANDALONE"), # Only relying on the Xenstore data
])
libxl_disk_specification = Enumeration("disk_specification", [
(0, "UNKNOWN"),
(1, "XEN"),
(2, "VIRTIO"),
])
libxl_disk_transport = Enumeration("disk_transport", [
(0, "UNKNOWN"),
(1, "MMIO"),
])
libxl_nic_type = Enumeration("nic_type", [
@@ -706,6 +718,12 @@ libxl_device_disk = Struct("device_disk", [
("is_cdrom", integer),
("direct_io_safe", bool),
("discard_enable", libxl_defbool),
("specification", libxl_disk_specification),
("transport", libxl_disk_transport),
# Note that virtio-mmio parameters (irq and base) are for internal use
# by libxl and can't be modified.
("irq", uint32),
("base", uint64),
# Note that the COLO configuration settings should be considered unstable.
# They may change incompatibly in future versions of Xen.
("colo_enable", libxl_defbool),
@@ -32,6 +32,7 @@ libxl__device_kind = Enumeration("device_kind", [
(14, "PVCALLS"),
(15, "VSND"),
(16, "VINPUT"),
(17, "VIRTIO_DISK"),
])
libxl__console_backend = Enumeration("console_backend", [
+2
View File
@@ -297,6 +297,8 @@ int libxl_string_to_backend(libxl_ctx *ctx, char *s, libxl_disk_backend *backend
*backend = LIBXL_DISK_BACKEND_TAP;
} else if (!strcmp(s, "qdisk")) {
*backend = LIBXL_DISK_BACKEND_QDISK;
} else if (!strcmp(s, "standalone")) {
*backend = LIBXL_DISK_BACKEND_STANDALONE;
} else if (!strcmp(s, "tap")) {
p = strchr(s, ':');
if (!p) {
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -694,7 +694,7 @@ extern int yylex (yyscan_t yyscanner);
#undef yyTABLES_NAME
#endif
#line 291 "libxlu_disk_l.l"
#line 300 "libxlu_disk_l.l"
#line 699 "libxlu_disk_l.h"
#undef xlu__disk_yyIN_HEADER
+9
View File
@@ -122,9 +122,17 @@ static void setbackendtype(DiskParseContext *dpc, const char *str) {
if ( !strcmp(str,"phy")) DSET(dpc,backend,BACKEND,str,PHY);
else if (!strcmp(str,"tap")) DSET(dpc,backend,BACKEND,str,TAP);
else if (!strcmp(str,"qdisk")) DSET(dpc,backend,BACKEND,str,QDISK);
else if (!strcmp(str,"standalone")) DSET(dpc,backend,BACKEND,str,STANDALONE);
else xlu__disk_err(dpc,str,"unknown value for backendtype");
}
/* Sets ->specification from the string. IDL should provide something for this. */
static void setspecification(DiskParseContext *dpc, const char *str) {
if (!strcmp(str,"xen")) DSET(dpc,specification,SPECIFICATION,str,XEN);
else if (!strcmp(str,"virtio")) DSET(dpc,specification,SPECIFICATION,str,VIRTIO);
else xlu__disk_err(dpc,str,"unknown value for specification");
}
/* Sets ->colo-port from the string. COLO need this. */
static void setcoloport(DiskParseContext *dpc, const char *str) {
int port = atoi(str);
@@ -192,6 +200,7 @@ devtype=[^,]*,? { xlu__disk_err(DPC,yytext,"unknown value for type"); }
access=[^,]*,? { STRIP(','); setaccess(DPC, FROMEQUALS); }
backend=[^,]*,? { STRIP(','); SAVESTRING("backend", backend_domname, FROMEQUALS); }
backendtype=[^,]*,? { STRIP(','); setbackendtype(DPC,FROMEQUALS); }
specification=[^,]*,? { STRIP(','); setspecification(DPC,FROMEQUALS); }
vdev=[^,]*,? { STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); }
script=[^,]*,? { STRIP(','); SAVESTRING("script", script, FROMEQUALS); }
+6
View File
@@ -119,6 +119,12 @@ int main_blockdetach(int argc, char **argv)
fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
return 1;
}
if (disk.specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
fprintf(stderr, "Hotunplug isn't supported for specification virtio\n");
return 1;
}
rc = !force ? libxl_device_disk_safe_remove(ctx, domid, &disk, 0) :
libxl_device_disk_destroy(ctx, domid, &disk, 0);
if (rc) {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.