mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemu: pass block pull backing file to monitor
This actually wires up the new optional parameter to block_stream: http://wiki.qemu.org/Features/LiveBlockMigration/ImageStreamingAPI The error checking is still sparse, since libvirt must not use qemu-img or header probing on a qcow2 file in use by qemu to check if the backing file name is valid; so for now, libvirt is relying on qemu to diagnose an incorrect backing name. Fixing this will require libvirt to track the entire backing file chain at the time qemu is started and keeps it updated with snapshot and pull operations. * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Add parameter, and update callers. * src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob): Update signature. * src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Likewise. * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Update caller. * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Likewise.
This commit is contained in:
parent
68a1300556
commit
10ec36e2e7
@ -11379,14 +11379,6 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
goto cleanup;
|
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)
|
if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -11399,7 +11391,12 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
priv = vm->privateData;
|
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);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
|
@ -2712,17 +2712,18 @@ int qemuMonitorScreendump(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
int qemuMonitorBlockJob(qemuMonitorPtr mon,
|
int qemuMonitorBlockJob(qemuMonitorPtr mon,
|
||||||
const char *device,
|
const char *device,
|
||||||
|
const char *base,
|
||||||
unsigned long bandwidth,
|
unsigned long bandwidth,
|
||||||
virDomainBlockJobInfoPtr info,
|
virDomainBlockJobInfoPtr info,
|
||||||
int mode)
|
int mode)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
VIR_DEBUG("mon=%p, device=%s, bandwidth=%lu, info=%p, mode=%o",
|
VIR_DEBUG("mon=%p, device=%s, base=%s, bandwidth=%lu, info=%p, mode=%o",
|
||||||
mon, device, bandwidth, info, mode);
|
mon, device, NULLSTR(base), bandwidth, info, mode);
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
ret = qemuMonitorJSONBlockJob(mon, device, bandwidth, info, mode);
|
ret = qemuMonitorJSONBlockJob(mon, device, base, bandwidth, info, mode);
|
||||||
else
|
else
|
||||||
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
|
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("block jobs require JSON monitor"));
|
_("block jobs require JSON monitor"));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* qemu_monitor.h: interaction with QEMU monitor console
|
* 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
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -519,9 +519,11 @@ typedef enum {
|
|||||||
|
|
||||||
int qemuMonitorBlockJob(qemuMonitorPtr mon,
|
int qemuMonitorBlockJob(qemuMonitorPtr mon,
|
||||||
const char *device,
|
const char *device,
|
||||||
|
const char *back,
|
||||||
unsigned long bandwidth,
|
unsigned long bandwidth,
|
||||||
virDomainBlockJobInfoPtr info,
|
virDomainBlockJobInfoPtr info,
|
||||||
int mode);
|
int mode)
|
||||||
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
|
||||||
|
|
||||||
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
|
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
|
||||||
const char *protocol,
|
const char *protocol,
|
||||||
|
@ -3229,17 +3229,25 @@ static int qemuMonitorJSONGetBlockJobInfo(virJSONValuePtr reply,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
|
int
|
||||||
const char *device,
|
qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
|
||||||
unsigned long bandwidth,
|
const char *device,
|
||||||
virDomainBlockJobInfoPtr info,
|
const char *base,
|
||||||
int mode)
|
unsigned long bandwidth,
|
||||||
|
virDomainBlockJobInfoPtr info,
|
||||||
|
int mode)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
const char *cmd_name = 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) {
|
if (mode == BLOCK_JOB_ABORT) {
|
||||||
cmd_name = "block_job_cancel";
|
cmd_name = "block_job_cancel";
|
||||||
cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device", device, NULL);
|
cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device", device, NULL);
|
||||||
@ -3254,8 +3262,12 @@ int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
|
|||||||
NULL);
|
NULL);
|
||||||
} else if (mode == BLOCK_JOB_PULL) {
|
} else if (mode == BLOCK_JOB_PULL) {
|
||||||
cmd_name = "block_stream";
|
cmd_name = "block_stream";
|
||||||
cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
|
if (base)
|
||||||
device, NULL);
|
cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
|
||||||
|
device, "s:base", base, NULL);
|
||||||
|
else
|
||||||
|
cmd = qemuMonitorJSONMakeCommand(cmd_name, "s:device",
|
||||||
|
device, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* qemu_monitor_json.h: interaction with QEMU monitor console
|
* 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
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -246,6 +246,7 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
|
int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
|
||||||
const char *device,
|
const char *device,
|
||||||
|
const char *base,
|
||||||
unsigned long bandwidth,
|
unsigned long bandwidth,
|
||||||
virDomainBlockJobInfoPtr info,
|
virDomainBlockJobInfoPtr info,
|
||||||
int mode);
|
int mode);
|
||||||
|
Loading…
Reference in New Issue
Block a user