if (!device) {
goto cleanup;
}
- /* XXX - add a qemu capability check; if qemu 1.1 or newer, then
- * validate and convert non-NULL base into something that can
- * be passed as optional base argument. */
- if (base) {
- qemuReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("partial block pull is not supported with this QEMU binary"));
- goto cleanup;
- }
if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
priv = vm->privateData;
- ret = qemuMonitorBlockJob(priv->mon, device, bandwidth, info, mode);
+ /* XXX - add a qemu capability check, since only qemu 1.1 or newer
+ * supports the base argument.
+ * XXX - libvirt should really be tracking the backing file chain
+ * itself, and validating that base is on the chain, rather than
+ * relying on qemu to do this. */
+ ret = qemuMonitorBlockJob(priv->mon, device, base, bandwidth, info, mode);
qemuDomainObjExitMonitorWithDriver(driver, vm);
endjob:
int qemuMonitorBlockJob(qemuMonitorPtr mon,
const char *device,
+ const char *base,
unsigned long bandwidth,
virDomainBlockJobInfoPtr info,
int mode)
{
int ret = -1;
- VIR_DEBUG("mon=%p, device=%s, bandwidth=%lu, info=%p, mode=%o",
- mon, device, bandwidth, info, mode);
+ VIR_DEBUG("mon=%p, device=%s, base=%s, bandwidth=%lu, info=%p, mode=%o",
+ mon, device, NULLSTR(base), bandwidth, info, mode);
if (mon->json)
- ret = qemuMonitorJSONBlockJob(mon, device, bandwidth, info, mode);
+ ret = qemuMonitorJSONBlockJob(mon, device, base, bandwidth, info, mode);
else
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("block jobs require JSON monitor"));
/*
* qemu_monitor.h: interaction with QEMU monitor console
*
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
int qemuMonitorBlockJob(qemuMonitorPtr mon,
const char *device,
+ const char *back,
unsigned long bandwidth,
virDomainBlockJobInfoPtr info,
- int mode);
+ int mode)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
const char *protocol,
}
-int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
- const char *device,
- unsigned long bandwidth,
- virDomainBlockJobInfoPtr info,
- int mode)
+int
+qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
+ const char *device,
+ const char *base,
+ unsigned long bandwidth,
+ virDomainBlockJobInfoPtr info,
+ int mode)
{
int ret = -1;
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
const char *cmd_name = NULL;
+ if (base && mode != BLOCK_JOB_PULL) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("only block pull supports base: %s"), base);
+ return -1;
+ }
+
if (mode == BLOCK_JOB_ABORT) {
cmd_name = "block_job_cancel";
cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device", device, NULL);
NULL);
} else if (mode == BLOCK_JOB_PULL) {
cmd_name = "block_stream";
- cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
- device, NULL);
+ if (base)
+ cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
+ device, "s:base", base, NULL);
+ else
+ cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
+ device, NULL);
}
if (!cmd)
/*
* qemu_monitor_json.h: interaction with QEMU monitor console
*
- * Copyright (C) 2006-2009, 2011 Red Hat, Inc.
+ * Copyright (C) 2006-2009, 2011-2012 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
const char *device,
+ const char *base,
unsigned long bandwidth,
virDomainBlockJobInfoPtr info,
int mode);