[libvirt] [PATCH 0/6] Enhancements in CPU selection
by Jiri Denemark
The main goal of this series is to provide an easy way to say that a guest CPU
should match host. Details can be found in individual patches.
Jiri Denemark (6):
tests: Print XML file name in verbose CPU test
cpu: Optionally forbid fallback CPU models
Add support for cpu mode attribute
cpu: Update guest CPU in host-* mode
Taint domains configured with cpu mode=host-passthrough
qemu: Add support for host CPU modes
docs/formatdomain.html.in | 12 +-
docs/schemas/domaincommon.rng | 32 +++
src/conf/capabilities.c | 2 +-
src/conf/cpu_conf.c | 264 +++++++++++++++-----
src/conf/cpu_conf.h | 38 +++-
src/conf/domain_conf.c | 5 +-
src/conf/domain_conf.h | 1 +
src/cpu/cpu.c | 2 +-
src/cpu/cpu_x86.c | 47 ++++-
src/libvirt_private.syms | 3 +
src/qemu/qemu_capabilities.c | 5 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 96 +++++---
src/qemu/qemu_domain.c | 15 +-
tests/cputest.c | 22 ++-
tests/cputestdata/x86-baseline-1-result.xml | 4 +-
tests/cputestdata/x86-baseline-2-result.xml | 4 +-
.../cputestdata/x86-baseline-no-vendor-result.xml | 4 +-
.../x86-baseline-some-vendors-result.xml | 4 +-
tests/cputestdata/x86-guest-nofallback.xml | 18 ++
.../cputestdata/x86-host+guest,model486-result.xml | 4 +-
.../x86-host+guest,models,Penryn-result.xml | 4 +-
.../x86-host+guest,models,qemu64-result.xml | 4 +-
tests/cputestdata/x86-host+guest,models-result.xml | 4 +-
tests/cputestdata/x86-host+guest-result.xml | 4 +-
tests/cputestdata/x86-host+guest.xml | 4 +-
...6-host+host+host-model,models,Penryn-result.xml | 19 ++
.../cputestdata/x86-host+host-model-nofallback.xml | 19 ++
tests/cputestdata/x86-host+host-model.xml | 18 ++
tests/cputestdata/x86-host+host-passthrough.xml | 18 ++
tests/cputestdata/x86-host+min.xml | 4 +-
.../cputestdata/x86-host+nehalem-force-result.xml | 4 +-
tests/cputestdata/x86-host+pentium3.xml | 4 +-
.../x86-host+strict-force-extra-result.xml | 4 +-
.../x86-host-better+pentium3,core2duo-result.xml | 4 +-
.../x86-host-better+pentium3,pentium3-result.xml | 4 +-
.../x86-host-better+pentium3-result.xml | 4 +-
tests/cputestdata/x86-host-model-nofallback.xml | 4 +
tests/cputestdata/x86-host-model.xml | 1 +
tests/cputestdata/x86-host-passthrough.xml | 1 +
tests/cputestdata/x86-host-worse+guest-result.xml | 4 +-
tests/qemuhelptest.c | 21 +-
tests/qemuxml2argvdata/qemu-lib.sh | 50 ++++
tests/qemuxml2argvdata/qemu-supported-cpus.sh | 15 ++
tests/qemuxml2argvdata/qemu.sh | 51 +----
tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml | 2 +-
.../qemuxml2argv-cpu-exact2-nofallback.args | 4 +
.../qemuxml2argv-cpu-exact2-nofallback.xml | 35 +++
.../qemuxml2argv-cpu-fallback.args | 19 ++
.../qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml | 25 ++
.../qemuxml2argv-cpu-host-model-fallback.args | 19 ++
.../qemuxml2argv-cpu-host-model-fallback.xml | 19 ++
.../qemuxml2argv-cpu-host-model-nofallback.xml | 21 ++
.../qemuxml2argv-cpu-host-model.args | 19 ++
.../qemuxml2argv-cpu-host-model.xml | 19 ++
.../qemuxml2argv-cpu-host-passthrough.args | 19 ++
.../qemuxml2argv-cpu-host-passthrough.xml | 19 ++
.../qemuxml2argv-cpu-nofallback.xml | 25 ++
.../qemuxml2argv-cpu-qemu-host-passthrough.xml | 19 ++
tests/qemuxml2argvtest.c | 91 +++++---
.../qemuxml2xmlout-graphics-spice-timeout.xml | 86 +++++++
tests/qemuxml2xmltest.c | 2 +-
tests/testutilsqemu.c | 2 +
63 files changed, 1053 insertions(+), 244 deletions(-)
create mode 100644 tests/cputestdata/x86-guest-nofallback.xml
create mode 100644 tests/cputestdata/x86-host+host+host-model,models,Penryn-result.xml
create mode 100644 tests/cputestdata/x86-host+host-model-nofallback.xml
create mode 100644 tests/cputestdata/x86-host+host-model.xml
create mode 100644 tests/cputestdata/x86-host+host-passthrough.xml
create mode 100644 tests/cputestdata/x86-host-model-nofallback.xml
create mode 100644 tests/cputestdata/x86-host-model.xml
create mode 100644 tests/cputestdata/x86-host-passthrough.xml
create mode 100644 tests/qemuxml2argvdata/qemu-lib.sh
create mode 100755 tests/qemuxml2argvdata/qemu-supported-cpus.sh
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2-nofallback.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-fallback.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-fallback.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-nofallback.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-passthrough.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-nofallback.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-qemu-host-passthrough.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
--
1.7.8.2
12 years, 10 months
[libvirt] [PATCH][TCK] add test for get and define save image xml
by Xiaoqiang Hu
add test for get and define save image xml and there are types of save image
file covered in the test: persistent, transient and invalid domain save image
---
scripts/qemu/400-save-image-xml.t | 107 +++++++++++++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 0 deletions(-)
create mode 100644 scripts/qemu/400-save-image-xml.t
diff --git a/scripts/qemu/400-save-image-xml.t b/scripts/qemu/400-save-image-xml.t
new file mode 100644
index 0000000..d584de1
--- /dev/null
+++ b/scripts/qemu/400-save-image-xml.t
@@ -0,0 +1,107 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2013 Red Hat, Inc.
+# Copyright (C) 2012-2013 Xiaoqiang Hu <xhu(a)redhat.com>
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+qemu/400-save-image-xml.t: test get and define xml from save image
+
+=head1 DESCRIPTION
+
+The test case validates that it is possible to define and get domain xml
+from save image. There are three types of save image file covered in the
+test: persistent, transient and invalid domain save image
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 10;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+ unlink "tck.img" if -f "tck.img";
+}
+
+SKIP:{
+ skip "Only relevant to QEMU driver", 10 unless $conn->get_type() eq "QEMU";
+
+ # scenario 1 - get/define xml from transient domain save image
+ my $xml = $tck->generic_domain("tck")->as_xml;
+ diag "Creating a new transient domain";
+ my $dom;
+ ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
+
+ unlink "tck.img" if -f "tck.img";
+ eval { $dom->save("tck.img"); };
+ SKIP: {
+ skip "save/restore not implemented", 9 if $@ && err_not_implemented($@);
+ ok(!$@, "domain saved");
+ die $@ if $@;
+
+ my ($savedxmldesc, $savefile);
+ $savefile = "tck.img";
+ diag "Checking that transient domain has gone away";
+ ok_error(sub { $conn->get_domain_by_name("tck") }, "NO_DOMAIN error raised from missing domain",
+ Sys::Virt::Error::ERR_NO_DOMAIN);
+ eval { $savedxmldesc = $conn->get_save_image_xml_description($savefile, 0); };
+ SKIP: {
+ skip "get/define save img xml not implemented", 7 if $@ && err_not_implemented($@);
+ $savedxmldesc = $conn->get_save_image_xml_description($savefile, 0);
+ $savedxmldesc =~ s/destroy/restart/g;
+ $conn->define_save_image_xml($savefile, $savedxmldesc, 0);
+
+ $savedxmldesc = $conn->get_save_image_xml_description($savefile, 0);
+ ok(!($savedxmldesc =~ m/destroy/), "the transient domain save image xml has been updated");
+
+ # scenario 2 - get/define xml from persistent domain save image
+ my $xml = $tck->generic_domain("tck")->as_xml;
+ diag "Creating a new persistent domain";
+ ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object");
+
+ unlink "tck.img" if -f "tck.img";
+ diag "Starting inactive domain";
+ $dom->create;
+
+ $dom->save("tck.img");
+ diag "Checking that persistent domain is stopped";
+ ok_domain(sub { $conn->get_domain_by_name("tck") }, "persistent domain is still there", "tck");
+ is($dom->get_id, -1, "running domain with ID == -1");
+
+ $savedxmldesc = $conn->get_save_image_xml_description($savefile, 0);
+ $savedxmldesc =~ s/destroy/restart/g;
+ $conn->define_save_image_xml($savefile, $savedxmldesc, 0);
+
+ $savedxmldesc = $conn->get_save_image_xml_description($savefile, 0);
+ ok(!($savedxmldesc =~ m/destroy/), "the persistent save image xml has been updated");
+
+ # scenario 3 - get/define xml from invalid domain save image
+ unlink "tck.img" if -f "tck.img";
+ diag "Creating an invalid save img file";
+ `dd if=/dev/null of=tck.img bs=1M count=100 >& /dev/null 2>&1`;
+ ok($? == 0, "created 100M raw img file: test.img");
+ $savefile = "tck.img";
+ diag "Getting xml from invalid save image";
+ ok_error(sub { $conn->get_save_image_xml_description($savefile, 0) }, "failed to get invalid domain save image xml" );
+ }
+ }
+}
+# end
--
1.7.1
12 years, 10 months
[libvirt] QMP: Supporting off tree APIs
by Luiz Capitulino
On Thu, 5 Jan 2012 13:48:43 +0000
Stefan Hajnoczi <stefanha(a)gmail.com> wrote:
> On Wed, Jan 4, 2012 at 12:59 PM, Luiz Capitulino <lcapitulino(a)redhat.com> wrote:
> > On Tue, 13 Dec 2011 13:52:27 +0000
> > Stefan Hajnoczi <stefanha(a)linux.vnet.ibm.com> wrote:
> >
> >> Add the block_stream command, which starts copy backing file contents
> >> into the image file. Later patches add control over the background copy
> >> speed, cancelation, and querying running streaming operations.
> >
> > Please also mention that you're adding an event, otherwise it comes as a
> > surprise to the reviewer.
>
> Ok.
>
> > When we talked about this implementation (ie. having events, cancellation etc)
> > I thought you were going to do something very specific to the streaming api,
> > like migration. However, you ended up adding async QMP support to the block
> > layer.
> >
> > I have the impression this could be generalized a bit more and be moved to
> > QMP instead (and I strongly feel that's what we should do).
> >
> > There's only one problem: we are waiting for the new QMP server to work on
> > that. I hope to have it integrated by the end of this month, but it might
> > be possible to add async support to the current server if waiting is not
> > an option.
>
> I'm not sure what you'd like here, could you be more specific? I have
> introduced the concept of a block job - a long-running operation on
> block devices - and the completion event when the job finishes. I
> guess you're thinking of a generic QMP job concept with a completion
> event?
Exactly. We should have QMP_JOB_COMPLETED instead of BLOCK_JOB_COMPLETED,
for example.
> Or something else?
>
> What I'd like to avoid at this stage is changing the QMP API as seen
> by clients because we already have at least one client which relies on
> this API. I know that sucks and that this is my fault because I've
> been dragging out this patch series for too long. But in a situation
> like this I think it's better to live with an API that doesn't meet
> the current philosophy on nice APIs but works flawlessly with both new
> and existing clients. But it depends on the specifics, what changes
> do you suggest?
[...]
> >> diff --git a/qapi-schema.json b/qapi-schema.json
> >> index fbbdbe0..65308d2 100644
> >> --- a/qapi-schema.json
> >> +++ b/qapi-schema.json
> >> @@ -901,3 +901,56 @@
> >> # Notes: Do not use this command.
> >> ##
> >> { 'command': 'cpu', 'data': {'index': 'int'} }
> >> +
> >> +##
> >> +# @block_stream:
> >
> > Command names should be verbs and please use an hyphen.
>
> These commands have been in the Image Streaming API spec from the beginning:
>
> http://wiki.qemu.org/Features/LiveBlockMigration/ImageStreamingAPI
>
> We cannot prettify the API at this stage. You, Anthony, and I
> discussed QAPI command naming on IRC maybe two months ago and this
> seemed to be the way to do it. These commands fit the existing
> block_* commands and are already in use by libvirt - if we change
> names now we break libvirt.
[...]
> >> +#
> >> +# Since: 1.1
> >> +##
> >> +{ 'command': 'block_stream', 'data': { 'device': 'str', '*base': 'str' } }
> >> diff --git a/qerror.c b/qerror.c
> >> index 14a1d59..605381a 100644
> >> --- a/qerror.c
> >> +++ b/qerror.c
> >> @@ -174,6 +174,10 @@ static const QErrorStringTable qerror_table[] = {
> >> .desc = "No '%(bus)' bus found for device '%(device)'",
> >> },
> >> {
> >> + .error_fmt = QERR_NOT_SUPPORTED,
> >> + .desc = "Not supported",
> >
> > We have QERR_UNSUPPORTED already.
>
> I know. We're stuck in a hard place here again because NotSupported
> has been in the Image Streaming API spec and hence implemented in
> libvirt for a while now. If we change this then an old client which
> only understands NotSupported will not know what to do with the
> Unsupported error.
>
> (Unsupported was not in QEMU when the Image Streaming API was defined.)
Let me try to understand it: is libvirt relying on an off tree API and
we are now required to have stable guarantees to off tree APIs?
I can't even express how insane this looks to me, at least not without
being too harsh.
12 years, 10 months
[libvirt] [PATCH] snapshot: allow reuse of existing files in disk snapshot
by Eric Blake
When disk snapshots were first implemented, libvirt blindly refused
to allow an external snapshot destination that already exists, since
qemu will blindly overwrite the contents of that file during the
snapshot_blkdev monitor command, and we don't like a default of
data loss by default. But VDSM has a scenario where NFS permissions
are intentionally set so that the destination file can only be
created by the management machine, and not the machine where the
guest is running, so that libvirt will necessarily see the destination
file already existing; adding a flag will allow VDSM to force the file
reuse without libvirt complaining of possible data loss.
https://bugzilla.redhat.com/show_bug.cgi?id=767104
* include/libvirt/libvirt.h.in (virDomainSnapshotCreateFlags): Add
VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT.
* src/libvirt.c (virDomainSnapshotCreateXML): Document it. Add
note about partial failure.
* tools/virsh.c (cmdSnapshotCreate, cmdSnapshotCreateAs): Add new
flag.
* tools/virsh.pod (snapshot-create, snapshot-create-as): Document
it.
* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare)
(qemuDomainSnapshotCreateXML): Implement the new flag.
---
I'm not sure I have the best name for the proposed flag; alternative
suggestions are welcome.
include/libvirt/libvirt.h.in | 2 ++
src/libvirt.c | 13 +++++++++++++
src/qemu/qemu_driver.c | 10 +++++++---
tools/virsh.c | 8 +++++++-
tools/virsh.pod | 16 +++++++++++++---
5 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index ad6fcce..0b564cf 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2990,6 +2990,8 @@ typedef enum {
after snapshot */
VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY = (1 << 4), /* disk snapshot, not
system checkpoint */
+ VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT = (1 << 5), /* reuse any existing
+ external files */
} virDomainSnapshotCreateFlags;
/* Take a snapshot of the current VM state */
diff --git a/src/libvirt.c b/src/libvirt.c
index c288f00..93d1504 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -16520,7 +16520,20 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot)
* inconsistent (as if power had been pulled), and specifying this
* with the VIR_DOMAIN_SNAPSHOT_CREATE_HALT flag risks data loss.
*
+ * By default, if the snapshot involves external files, and any of the
+ * destination files already exist as a regular file, the snapshot is
+ * rejected to avoid losing contents of those files. However, if
+ * @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT, then existing
+ * destination files are instead truncated and reused.
+ *
* Returns an (opaque) virDomainSnapshotPtr on success, NULL on failure.
+ * Be aware that although libvirt prefers to report errors up front with
+ * no other effect, there are certain types of failures where a failure
+ * can occur even though the guest configuration was changed (for
+ * example, if a disk snapshot request over two disks only fails on the
+ * second disk, leaving the first disk altered); so after getting a NULL
+ * return, it can be wise to use virDomainGetXMLDesc() to determine if
+ * any partial changes occurred.
*/
virDomainSnapshotPtr
virDomainSnapshotCreateXML(virDomainPtr domain,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1a7e816..9765a69 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9693,7 +9693,8 @@ endjob:
}
static int
-qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def)
+qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def,
+ bool allow_reuse)
{
int ret = -1;
int i;
@@ -9746,7 +9747,7 @@ qemuDomainSnapshotDiskPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def)
disk->name, disk->file);
goto cleanup;
}
- } else if (!S_ISBLK(st.st_mode)) {
+ } else if (!(S_ISBLK(st.st_mode) || allow_reuse)) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("external snapshot file for disk %s already "
"exists and is not a block device: %s"),
@@ -10162,11 +10163,14 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
goto cleanup;
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) {
+ bool allow_reuse;
+
+ allow_reuse = (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
if (virDomainSnapshotAlignDisks(def,
VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL,
false) < 0)
goto cleanup;
- if (qemuDomainSnapshotDiskPrepare(vm, def) < 0)
+ if (qemuDomainSnapshotDiskPrepare(vm, def, allow_reuse) < 0)
goto cleanup;
def->state = VIR_DOMAIN_DISK_SNAPSHOT;
} else {
diff --git a/tools/virsh.c b/tools/virsh.c
index e4b812e..04c1f6e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1,7 +1,7 @@
/*
* virsh.c: a shell to exercise the libvirt API
*
- * Copyright (C) 2005, 2007-2011 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2012 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -14462,6 +14462,7 @@ static const vshCmdOptDef opts_snapshot_create[] = {
{"no-metadata", VSH_OT_BOOL, 0, N_("take snapshot but create no metadata")},
{"halt", VSH_OT_BOOL, 0, N_("halt domain after snapshot is created")},
{"disk-only", VSH_OT_BOOL, 0, N_("capture disk state but not vm state")},
+ {"reuse-external", VSH_OT_BOOL, 0, N_("reuse any existing external files")},
{NULL, 0, 0, NULL}
};
@@ -14484,6 +14485,8 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_HALT;
if (vshCommandOptBool(cmd, "disk-only"))
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
+ if (vshCommandOptBool(cmd, "reuse-external"))
+ flags |= VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -14592,6 +14595,7 @@ static const vshCmdOptDef opts_snapshot_create_as[] = {
{"no-metadata", VSH_OT_BOOL, 0, N_("take snapshot but create no metadata")},
{"halt", VSH_OT_BOOL, 0, N_("halt domain after snapshot is created")},
{"disk-only", VSH_OT_BOOL, 0, N_("capture disk state but not vm state")},
+ {"reuse-external", VSH_OT_BOOL, 0, N_("reuse any existing external files")},
{"diskspec", VSH_OT_ARGV, 0,
N_("disk attributes: disk[,snapshot=type][,driver=type][,file=name]")},
{NULL, 0, 0, NULL}
@@ -14615,6 +14619,8 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_HALT;
if (vshCommandOptBool(cmd, "disk-only"))
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
+ if (vshCommandOptBool(cmd, "reuse-external"))
+ flags |= VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 138f886..1abf448 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2024,7 +2024,7 @@ used to represent properties of snapshots.
=over 4
=item B<snapshot-create> I<domain> [I<xmlfile>] {[I<--redefine> [I<--current>]]
-| [I<--no-metadata>] [I<--halt>] [I<--disk-only>]}
+| [I<--no-metadata>] [I<--halt>] [I<--disk-only>] [I<--reuse-external]}
Create a snapshot for domain I<domain> with the properties specified in
I<xmlfile>. Normally, the only properties settable for a domain snapshot
@@ -2061,14 +2061,19 @@ treat the snapshot as current, and cannot revert to the snapshot
unless I<--redefine> is later used to teach libvirt about the
metadata again).
+If I<--reuse-external> is specified, and the snapshot XML requests an
+external snapshot with a destination of an existing file, then the
+existing file is truncated and reused; otherwise, a snapshot is refused
+to avoid losing contents of the existing files.
+
Existence of snapshot metadata will prevent attempts to B<undefine>
a persistent domain. However, for transient domains, snapshot
metadata is silently lost when the domain quits running (whether
by command such as B<destroy> or by internal guest action).
=item B<snapshot-create-as> I<domain> {[I<--print-xml>]
-| [I<--no-metadata>] [I<--halt>]} [I<name>] [I<description>]
-[I<--disk-only> [[I<--diskspec>] B<diskspec>]...
+| [I<--no-metadata>] [I<--halt>] [I<--reuse-existing>]} [I<name>]
+[I<description>] [I<--disk-only> [[I<--diskspec>] B<diskspec>]...]
Create a snapshot for domain I<domain> with the given <name> and
<description>; if either value is omitted, libvirt will choose a
@@ -2091,6 +2096,11 @@ results in the following XML:
<source file='/path/to,new'/>
</disk>
+If I<--reuse-external> is specified, and the domain XML or I<diskspec>
+option requests an external snapshot with a destination of an existing
+file, then the existing file is truncated and reused; otherwise, a
+snapshot is refused to avoid losing contents of the existing files.
+
If I<--no-metadata> is specified, then the snapshot data is created,
but any metadata is immediately discarded (that is, libvirt does not
treat the snapshot as current, and cannot revert to the snapshot
--
1.7.7.5
12 years, 10 months
[libvirt] [PATCH] Docs: Improve documents for several APIs
by Osier Yang
virDomainGetBlockIoTune uses virTypedParameterFlags actually. And
The definition of virTypedParameterFlags contains virDomainModificationImpact.
---
src/libvirt.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index c288f00..896d151 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3691,7 +3691,7 @@ error:
* @params: pointer to memory parameter object
* (return value, allocated by the caller)
* @nparams: pointer to number of memory parameters; input and output
- * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
+ * @flags: bitwise-OR of virTypedParameterFlags
*
* Get all memory parameters. On input, @nparams gives the size of the
* @params array; on output, @nparams gives how many slots were filled
@@ -3833,7 +3833,7 @@ error:
* @params: pointer to numa parameter object
* (return value, allocated by the caller)
* @nparams: pointer to number of numa parameters
- * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
+ * @flags: bitwise-OR of virTypedParameterFlags
*
* Get all numa parameters. On input, @nparams gives the size of the
* @params array; on output, @nparams gives how many slots were filled
@@ -3961,7 +3961,7 @@ error:
* @params: pointer to blkio parameter object
* (return value, allocated by the caller)
* @nparams: pointer to number of blkio parameters; input and output
- * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
+ * @flags: bitwise-OR of virTypedParameterFlags
*
* Get all blkio parameters. On input, @nparams gives the size of the
* @params array; on output, @nparams gives how many slots were filled
@@ -6670,7 +6670,7 @@ error:
* @nparams: pointer to number of scheduler parameter
* (this value should be same than the returned value
* nparams of virDomainGetSchedulerType()); input and output
- * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
+ * @flags: bitwise-OR of virTypedParameterFlags
*
* Get all scheduler parameters. On input, @nparams gives the size of the
* @params array; on output, @nparams gives how many slots were filled
@@ -7149,7 +7149,7 @@ error:
* @params: pointer to interface parameter objects
* (return value, allocated by the caller)
* @nparams: pointer to number of interface parameter; input and output
- * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
+ * @flags: bitwise-OR of virTypedParameterFlags
*
* Get all interface parameters. On input, @nparams gives the size of
* the @params array; on output, @nparams gives how many slots were
@@ -17790,7 +17790,7 @@ error:
* @params: Pointer to blkio parameter object
* (return value, allocated by the caller)
* @nparams: Pointer to number of blkio parameters
- * @flags: An OR'ed set of virDomainModificationImpact
+ * @flags: bitwise-OR of virTypedParameterFlags
*
* Get all block IO tunable parameters for a given device. On input,
* @nparams gives the size of the @params array; on output, @nparams
--
1.7.7.3
12 years, 10 months
[libvirt] [PATCH] qemu: check for kvm availability before starting kvm guests
by Laine Stump
This *kind of* addresses:
https://bugzilla.redhat.com/show_bug.cgi?id=772395
(it doesn't eliminate the failure to start, but causes libvirt to give
a better idea about the cause of the failure).
If a guest uses a kvm emulator (e.g. /usr/bin/qemu-kvm) and the guest
is started when kvm isn't available (either because virtualization is
unavailable / has been disabled in the BIOS, or the kvm modules
haven't been loaded for some reason), a semi-cryptic error message is
logged:
libvirtError: internal error Child process (LC_ALL=C
PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/bin/qemu-kvm -device ? -device
pci-assign,? -device virtio-blk-pci,? -device virtio-net-pci,?) status
unexpected: exit status 1
This patch notices at process start that a guest needs kvm, and checks
for the presence of /dev/kvm (a reasonable indicator that kvm is
available) before trying to execute the qemu binary. If kvm isn't
available, a more useful (too verbose??) error is logged.
---
src/qemu/qemu_process.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 105b895..e0fd073 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3031,6 +3031,17 @@ int qemuProcessStart(virConnectPtr conn,
if ((logfile = qemuDomainCreateLog(driver, vm, false)) < 0)
goto cleanup;
+ if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) {
+ VIR_DEBUG("Checking for KVM availability");
+ if (access("/dev/kvm", F_OK) != 0) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Domain requires KVM, but it is not available. "
+ "Check that virtualization is enabled in the host BIOS, "
+ "and host configuration is setup to load the kvm modules."));
+ goto cleanup;
+ }
+ }
+
VIR_DEBUG("Determining emulator version");
qemuCapsFree(priv->qemuCaps);
priv->qemuCaps = NULL;
--
1.7.7.4
12 years, 10 months
[libvirt] [PATCH] qemu: fix a typo on qemuDomainSetBlkioParameters
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
It should be a copy-paste error, the result is programming will result in an
infinite loop again due to without iterating 'j' variable.
* src/qemu/qemu_driver.c: fix a typo on qemuDomainSetBlkioParameters.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770520
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1a7e816..383b2be 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6002,7 +6002,7 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom,
ret = -1;
continue;
}
- for (j = 0; j < ndevices; i++) {
+ for (j = 0; j < ndevices; j++) {
rc = virCgroupSetBlkioDeviceWeight(group,
devices[j].path,
devices[j].weight);
--
1.7.1
12 years, 10 months
[libvirt] [PATCH libvirt-glib] Fix libvirt error message after finishing a stream
by Marc-André Lureau
The callback is now added & removed from libvirt-gobject-stream.c
It should have been part of c5a239423a215435626bf6d1af75458c5ec03147.
#0 virErrorMsg (error=VIR_ERR_INTERNAL_ERROR, info=0x7fffffffcf00 "no stream callback registered") at util/virterror.c:760
#1 0x00007ffff627f304 in virReportErrorHelper (domcode=7, errcode=1, filename=0x7ffff6479a4d "rpc/virnetclientstream.c",
funcname=0x7ffff6479ca0 "virNetClientStreamEventRemoveCallback", linenr=514, fmt=<optimized out>) at util/virterror.c:1260
#2 0x00007ffff6339aa4 in virNetClientStreamEventRemoveCallback (st=0x1de8ef0) at rpc/virnetclientstream.c:513
#3 0x00007ffff631a6ba in remoteStreamEventRemoveCallback (st=<optimized out>) at remote/remote_driver.c:3713
#4 0x00007ffff62fe97d in virStreamEventRemoveCallback (stream=0x1db9e00) at libvirt.c:14781
#5 0x00007ffff69114f3 in gvir_stream_update_events (stream=0x1db2570) at libvirt-gobject-stream.c:561
#6 0x00007ffff6911616 in gvir_stream_source_finalize (source=0x1da25e0) at libvirt-gobject-stream.c:606
---
libvirt-gobject/libvirt-gobject-input-stream.c | 1 -
libvirt-gobject/libvirt-gobject-output-stream.c | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-input-stream.c b/libvirt-gobject/libvirt-gobject-input-stream.c
index 733049b..29d1c29 100644
--- a/libvirt-gobject/libvirt-gobject-input-stream.c
+++ b/libvirt-gobject/libvirt-gobject-input-stream.c
@@ -197,7 +197,6 @@ static gssize gvir_input_stream_read_finish(GInputStream *stream,
count = g_simple_async_result_get_op_res_gssize(simple);
- virStreamEventRemoveCallback(handle);
virStreamFree(handle);
return count;
diff --git a/libvirt-gobject/libvirt-gobject-output-stream.c b/libvirt-gobject/libvirt-gobject-output-stream.c
index bb82bd3..88fff85 100644
--- a/libvirt-gobject/libvirt-gobject-output-stream.c
+++ b/libvirt-gobject/libvirt-gobject-output-stream.c
@@ -197,7 +197,6 @@ static gssize gvir_output_stream_write_finish(GOutputStream *stream,
count = g_simple_async_result_get_op_res_gssize(simple);
- virStreamEventRemoveCallback(handle);
virStreamFree(handle);
return count;
--
1.7.7.5
12 years, 10 months
[libvirt] [PATCH 0/4] New command for changing media of changeable disk
by Osier Yang
This is an improved version of :
https://www.redhat.com/archives/libvir-list/2011-December/msg00976.html
The changes are:
* New helper functions to find and change the disk XML
* Use the helper functions in cmdDetachDisk
* Merge insert-media and eject-media as change-media
* Support --update option.
[PATCH 0/4] introduces two new helper functions: vshFindDisk is to find
the disk XML node in xml doc with the flags (indicates it's normal disk
or changeable disk). VshPrepareDiskXML is to prepare the disk XML for
disk changing commands' use. Such as detach-disk. The purpose of this
patch is to prepare for upcoming new command "change-disk", which will
use the two helper functions too.
NB, as I explained previously, the new QEMU commands to separate tray
and media management shouldn't block us.
[PATCH 1/4] virsh: Two new helper functions for disk device changes
[PATCH 2/4] virsh: Use vshFindDisk and vshPrepareDiskXML in
[PATCH 3/4] virsh: New command cmdChangeMedia
[PATCH 4/4] virsh: Add document for cmdChangeMedia
Regards,
Osier
12 years, 10 months