[libvirt] [PATCH] build: silence gcc warning
by Eric Blake
util/virpidfile.c: In function 'virPidFileAcquirePath':
util/virpidfile.c:308:66: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]
* src/util/virpidfile.c (virPidFileAcquirePath): Move verify to
top level.
---
Pushing under the build-breaker rule.
src/util/virpidfile.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 38cc7e2..7dd3c51 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -299,13 +299,13 @@ cleanup:
}
+verify(sizeof(pid_t) <= sizeof(unsigned int));
int virPidFileAcquirePath(const char *path,
pid_t pid)
{
int fd = -1;
char pidstr[INT_BUFSIZE_BOUND(pid)];
- verify(sizeof(pid_t) <= sizeof(unsigned int));
if (path[0] == '\0')
return 0;
--
1.7.4.4
13 years, 7 months
[libvirt] [BUG?] killall -SIGHUP libvirtd / virStateReload
by Philipp Hahn
Hello,
did something happen to sending SIGHUP to libvirtd? I can't find where the
hook for SIGHUP is installed and virStateReload() seems to be uncalled.
In 0.8.4 that was handled from qemudDispatchSignalEvent(), which seems to be
gone.
At least the manual page should be updated?
Sincerely
Philipp
--
Philipp Hahn Open Source Software Engineer hahn(a)univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99
http://www.univention.de/
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index 6e699b8..8b39395 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -66,10 +66,6 @@ Display version information then exit.
=back
-=head1 SIGNALS
-
-On receipt of B<SIGHUP> libvirtd will reload its configuration.
-
=head1 FILES
=over
13 years, 7 months
[libvirt] [PATCH] snapshot: one less point of failure in qemu
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=727709
mentions that if qemu fails to create the snapshot (such as what
happens on Fedora 15 qemu, which has qmp but where savevm is only
in hmp, and where libvirt is old enough to not try the hmp fallback),
then 'virsh snapshot-list dom' will show a garbage snapshot entry,
and the libvirt internal directory for storing snapshot metadata.
This fixes the fallout bug of polluting the snapshot-list with
garbage on failure (the root cause of the F15 bug of not having
fallback to hmp has already been fixed in newer libvirt releases).
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Allocate
memory before making snapshot, and cleanup on failure.
---
src/qemu/qemu_driver.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7802e08..da2703e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8665,7 +8665,7 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
virDomainSnapshotObjPtr snap = NULL;
virDomainSnapshotPtr snapshot = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN];
- virDomainSnapshotDefPtr def;
+ virDomainSnapshotDefPtr def = NULL;
virCheckFlags(0, NULL);
@@ -8695,6 +8695,13 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
goto cleanup;
snap->def->state = virDomainObjGetState(vm, NULL);
+ if (vm->current_snapshot) {
+ def->parent = strdup(vm->current_snapshot->def->name);
+ if (def->parent == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
/* actually do the snapshot */
if (!virDomainObjIsActive(vm)) {
@@ -8711,14 +8718,6 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
* on it, so we have to go forward the best we can
*/
- if (vm->current_snapshot) {
- def->parent = strdup(vm->current_snapshot->def->name);
- if (def->parent == NULL) {
- virReportOOMError();
- goto cleanup;
- }
- }
-
/* Now we set the new current_snapshot for the domain */
vm->current_snapshot = snap;
@@ -8732,6 +8731,12 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
cleanup:
if (vm)
virDomainObjUnlock(vm);
+ if (!snapshot) {
+ if (snap)
+ virDomainSnapshotObjListRemove(&vm->snapshots, snap);
+ else
+ virDomainSnapshotDefFree(def);
+ }
qemuDriverUnlock(driver);
return snapshot;
}
--
1.7.4.4
13 years, 7 months
[libvirt] [PATCH 0/6] snapshot work - don't strand snapshot metadata
by Eric Blake
Maps pretty well to my RFC email trail, as amended with followups:
https://www.redhat.com/archives/libvir-list/2011-August/msg00452.html
The qemu_driver diffstat is deceptively large; there's some code motion
thrown in on 3/6.
This series requires acks on the earlier one:
https://www.redhat.com/archives/libvir-list/2011-August/msg00493.html
Eric Blake (6):
snapshot: identify which snapshots have metadata
snapshot: prevent stranding snapshot data on domain destruction
snapshot: refactor some qemu code
snapshot: cache qemu-img location
snapshot: support new undefine flags in qemu
snapshot: teach virsh about new undefine flags
include/libvirt/libvirt.h.in | 29 +++-
src/esx/esx_driver.c | 17 ++-
src/libvirt.c | 58 +++++-
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 336 +++++++++++++++++++++--------------
src/vbox/vbox_tmpl.c | 19 ++-
tools/virsh.c | 400 +++++++++++++++++++++++++++++++++++++-----
tools/virsh.pod | 36 ++++-
8 files changed, 691 insertions(+), 205 deletions(-)
--
1.7.4.4
13 years, 7 months
[libvirt] [PATCH] virsh: fix logic bug
by Eric Blake
Bug introduced in commit 9a0ec36.
* tools/virsh.c (cmdUndefine): Add missing line.
---
Pushing under the trivial rule.
tools/virsh.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 070d461..f995ae6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1449,6 +1449,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+ return false;
has_managed_save = virDomainHasManagedSaveImage(dom, 0);
if (has_managed_save < 0) {
--
1.7.4.4
13 years, 7 months
[libvirt] [PATCH 0/5] Some rearrangement & additions to pid file handling/locking
by Daniel P. Berrange
This series is a collection of changes related to pidfiles. First
we define some wrappers around fcntl()'s lock file capability.
Then all existing pidfile APIs from src/util/util.h are moved into
a new file src/util/virpidfile.h. Next a new API for doing a sanity
check on a PID (using /proc/$PID/exe) is introduced. Then two clever
functions for doing race free, crash-safe acquisition & release of
pidfiles are introduced. Finally libvirtd is converted to use the
new pidfile acquisition API.
13 years, 7 months
[libvirt] [PATCH 1/3] snapshot: allow deletion of just snapshot metadata
by Eric Blake
A future patch will make it impossible to remove a domain if it
would leave behind any libvirt-tracked metadata about snapshots,
since stale metadata interferes with a new domain by the same name.
But requiring snaphot contents to be deleted before removing a
domain is harsh; with qemu, qemu-img can still make use of the
contents after the libvirt domain is gone. Therefore, we need
an option to get rid of libvirt tracking information, but not
the actual contents. For hypervisors that do not track any
metadata in libvirt, the implementation is trivial; all remaining
hypervisors (really, just qemu) will be dealt with separately.
* include/libvirt/libvirt.h.in
(VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY): New flag.
* src/libvirt.c (virDomainSnapshotDelete): Document it.
* src/esx/esx_driver.c (esxDomainSnapshotDelete): Trivially
supported when there is no libvirt metadata.
* src/vbox/vbox_tmpl.c (vboxDomainSnapshotDelete): Likewise.
---
Progress towards implementing my RFC. Patch 2/3 took a lot more of
my time to diagnose and fix than I was expecting.
include/libvirt/libvirt.h.in | 1 +
src/esx/esx_driver.c | 10 +++++++++-
src/libvirt.c | 10 +++++++---
src/vbox/vbox_tmpl.c | 10 +++++++++-
4 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index a625479..3aec4b0 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2580,6 +2580,7 @@ int virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
/* Delete a snapshot */
typedef enum {
VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN = (1 << 0),
+ VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY = (2 << 0),
} virDomainSnapshotDeleteFlags;
int virDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c097651..beeafbd 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4543,7 +4543,8 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
esxVI_TaskInfoState taskInfoState;
char *taskInfoErrorMessage = NULL;
- virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
+ virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
+ VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1);
if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
@@ -4561,6 +4562,13 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
goto cleanup;
}
+ /* ESX snapshots do not require any libvirt metadata, making this
+ * flag trivial once we know we have a valid snapshot. */
+ if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY) {
+ result = 0;
+ goto cleanup;
+ }
+
if (esxVI_RemoveSnapshot_Task(priv->primary, snapshotTree->snapshot,
removeChildren, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
diff --git a/src/libvirt.c b/src/libvirt.c
index c8af3e1..8ee9e96 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -15792,14 +15792,18 @@ error:
/**
* virDomainSnapshotDelete:
* @snapshot: a domain snapshot object
- * @flags: flag parameters
+ * @flags: bitwise-or of supported virDomainSnapshotDeleteFlags
*
* Delete the snapshot.
*
* If @flags is 0, then just this snapshot is deleted, and changes from
* this snapshot are automatically merged into children snapshots. If
- * flags is VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, then this snapshot
- * and any children snapshots are deleted.
+ * @flags includes VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, then this snapshot
+ * and any children snapshots are deleted. If @flags includes
+ * VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, then any snapshot metadata
+ * tracked by libvirt is removed while keeping the snapshot contents
+ * intact; if a hypervisor does not require any libvirt metadata to
+ * track snapshots, then this flag results in no changes.
*
* Returns 0 if the snapshot was successfully deleted, -1 on error.
*/
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 822e899..8de2bae 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -6361,7 +6361,8 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
PRUint32 state;
nsresult rc;
- virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
+ virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
+ VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1);
vboxIIDFromUUID(&domiid, dom->uuid);
rc = VBOX_OBJECT_GET_MACHINE(domiid.value, &machine);
@@ -6382,6 +6383,13 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
goto cleanup;
}
+ /* VBOX snapshots do not require any libvirt metadata, making this
+ * flag trivial once we know we have a valid snapshot. */
+ if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY) {
+ ret = 0;
+ goto cleanup;
+ }
+
if (state >= MachineState_FirstOnline
&& state <= MachineState_LastOnline) {
vboxError(VIR_ERR_OPERATION_INVALID, "%s",
--
1.7.4.4
13 years, 7 months
[libvirt] [PATCH 1/2] virsh: don't reject undefine on active domain
by Eric Blake
The public API documents that undefine may be used to transition a
running persistent domain into a transient one. Many drivers still
do not support this usage, but virsh shouldn't be getting in the
way of those that do support it.
* tools/virsh.c (cmdUndefine): Allow undefine on active domains;
the drivers may still reject it, but it is a valid API usage.
* tests/undefine (error): Fix the test to match.
---
tests/undefine | 9 +++++----
tools/virsh.c | 15 +--------------
2 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/tests/undefine b/tests/undefine
index f89a91e..5c39e27 100755
--- a/tests/undefine
+++ b/tests/undefine
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise virsh's "undefine" command
-# Copyright (C) 2008-2009 Red Hat, Inc.
+# Copyright (C) 2008-2009, 2011 Red Hat, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@ fi
fail=0
# Attempt to undefine a running domain, by domain name.
+# Although the API allows this, the test hypervisor does not.
$abs_top_builddir/tools/virsh -q -c test:///default undefine test > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
@@ -38,12 +39,12 @@ error: internal error Domain 'test' is still running
EOF
compare exp out || fail=1
-# A different diagnostic when specifying a domain ID
+# A similar diagnostic when specifying a domain ID
$abs_top_builddir/tools/virsh -q -c test:///default undefine 1 > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
-error: a running domain like 1 cannot be undefined;
-to undefine, first shutdown then undefine using its name or UUID
+error: Failed to undefine domain 1
+error: internal error Domain 'test' is still running
EOF
compare exp out || fail=1
diff --git a/tools/virsh.c b/tools/virsh.c
index b0d43ba..371e010 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1431,7 +1431,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
bool ret = true;
const char *name = NULL;
- int id;
int flags = 0;
int managed_save = vshCommandOptBool(cmd, "managed-save");
int has_managed_save = 0;
@@ -1449,19 +1448,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptString(cmd, "domain", &name) <= 0)
return false;
- if (name && virStrToLong_i(name, NULL, 10, &id) == 0
- && id >= 0 && (dom = virDomainLookupByID(ctl->conn, id))) {
- vshError(ctl,
- _("a running domain like %s cannot be undefined;\n"
- "to undefine, first shutdown then undefine"
- " using its name or UUID"),
- name);
- virDomainFree(dom);
- return false;
- }
- if (!(dom = vshCommandOptDomainBy(ctl, cmd, &name,
- VSH_BYNAME|VSH_BYUUID)))
- return false;
+ if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
has_managed_save = virDomainHasManagedSaveImage(dom, 0);
if (has_managed_save < 0) {
--
1.7.4.4
13 years, 7 months
[libvirt] [PATCH 0/3] apibuild improvements
by Philipp Hahn
While working with the documentation, I found some issues I'd like to
improve.
Philipp Hahn (3):
Align table cells on top
Improve tokenizing of linkable terms
Fix references to self.warning()
docs/apibuild.py | 48 ++++++++++++++++++++++++++++++------------------
docs/libvirt.css | 4 ++++
docs/newapi.xsl | 9 ++++++---
3 files changed, 40 insertions(+), 21 deletions(-)
13 years, 7 months