[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V3 13/13] libxl: Remove a passthrough device through
From: |
Anthony PERARD |
Subject: |
[Qemu-devel] [PATCH V3 13/13] libxl: Remove a passthrough device through QMP. |
Date: |
Tue, 1 Nov 2011 16:07:26 +0000 |
Signed-off-by: Anthony PERARD <address@hidden>
---
tools/libxl/libxl_pci.c | 69 ++++++++++++++++++++++++++++++----------------
1 files changed, 45 insertions(+), 24 deletions(-)
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 207ee33..1f93e67 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -861,13 +861,45 @@ out:
return rc;
}
+static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid,
+ libxl_device_pci *pcidev, int force)
+{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+ char *state;
+ char *path;
+
+ path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid);
+ state = libxl__xs_read(gc, XBT_NULL, path);
+ path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter",
domid);
+ libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain,
+ pcidev->bus, pcidev->dev, pcidev->func);
+ path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
domid);
+
+ /* Remove all functions at once atomically by only signalling
+ * device-model for function 0 */
+ if ( !force && (pcidev->vdevfn & 0x7) == 0 ) {
+ xs_write(ctx->xsh, XBT_NULL, path, "pci-rem", strlen("pci-rem"));
+ if (libxl__wait_for_device_model(gc, domid, "pci-removed",
+ NULL, NULL, NULL) < 0) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model didn't respond in
time");
+ /* This depends on guest operating system acknowledging the
+ * SCI, if it doesn't respond in time then we may wish to
+ * force the removal.
+ */
+ return ERROR_FAIL;
+ }
+ }
+ path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid);
+ xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state));
+
+ return 0;
+}
+
static int do_pci_remove(libxl__gc *gc, uint32_t domid,
libxl_device_pci *pcidev, int force)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
libxl_device_pci *assigned;
- char *path;
- char *state;
int hvm = 0, rc, num;
int stubdomid = 0;
@@ -886,29 +918,18 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
NULL, NULL, NULL) < 0) {
return ERROR_FAIL;
}
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state",
domid);
- state = libxl__xs_read(gc, XBT_NULL, path);
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/parameter",
domid);
- libxl__xs_write(gc, XBT_NULL, path, PCI_BDF, pcidev->domain,
- pcidev->bus, pcidev->dev, pcidev->func);
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
domid);
-
- /* Remove all functions at once atomically by only signalling
- * device-model for function 0 */
- if ( !force && (pcidev->vdevfn & 0x7) == 0 ) {
- xs_write(ctx->xsh, XBT_NULL, path, "pci-rem", strlen("pci-rem"));
- if (libxl__wait_for_device_model(gc, domid, "pci-removed",
- NULL, NULL, NULL) < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model didn't respond
in time");
- /* This depends on guest operating system acknowledging the
- * SCI, if it doesn't respond in time then we may wish to
- * force the removal.
- */
- return ERROR_FAIL;
- }
+ switch (libxl__device_model_version_running(gc, domid)) {
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
+ rc = qemu_pci_remove_xenstore(gc, domid, pcidev, force);
+ break;
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+ rc = libxl__qmp_pci_del(gc, domid, pcidev);
+ break;
+ default:
+ return ERROR_INVAL;
}
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state",
domid);
- xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state));
+ if (rc)
+ return ERROR_FAIL;
break;
case LIBXL_DOMAIN_TYPE_PV:
{
--
Anthony PERARD
- [Qemu-devel] [PATCH V3 00/13] libxl: QMP client improvement + pci passthrougth insert through QMP, Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 03/13] libxl_qmp: Better error message after a parse error., Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 05/13] libxl_qmp: Introduce an opaque argument to the callbacks., Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 01/13] libxl_qmp: Fix return check of fcntl, Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 08/13] libxl_qmp: Introduce qmp_request_context., Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 10/13] libxl_qmp: Introduce libxl__qmp_pci_add., Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 02/13] libxl_json: Check the parser status before to call parse_complete, Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 11/13] libxl: Use QMP to insert a passthrough device when using upstream QEMU, Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 13/13] libxl: Remove a passthrough device through QMP.,
Anthony PERARD <=
- [Qemu-devel] [PATCH V3 06/13] libxl_qmp: Introduce list of arguments to qmp_send, Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 09/13] libxl_json: Handle number abrove LONG_MAX., Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 12/13] libxl_qmp: Introduce libxl__qmp_pci_del, Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 04/13] libxl: Introduce dm-version xenstore key., Anthony PERARD, 2011/11/01
- [Qemu-devel] [PATCH V3 07/13] libxl_qmp: Always insert a command id in the callback_list., Anthony PERARD, 2011/11/01
- Re: [Qemu-devel] [PATCH V3 00/13] libxl: QMP client improvement + pci passthrougth insert through QMP, Anthony PERARD, 2011/11/01