I wonder if there's a reason why it is not possible to dump the core
of a KVM domain which is set to autodestroy.
$ virsh dump guestfs-4xe592eyqq4rfnk9 /tmp/guestfs-4xe592eyqq4rfnk9.core
error: Failed to core dump domain guestfs-4xe592eyqq4rfnk9 to
/tmp/guestfs-4xe592eyqq4rfnk9.core
error: Requested operation is not valid: domain is marked for auto destroy
All libguestfs domains have the autodestroy flag, but I am trying to
debug one which is crashing in the guest (RHBZ#1269779) and having the
ability to dump it would be very helpful.
I added the following patch to libvirt, which allowed me to dump the
domain with no apparent ill effects.
(The patch is a bit of a hack, and I did not check it very closely, so
it's probably not suitable for going upstream).
Rich.
From ffb899e436c15974b0f42b1cbd8337701c3a05d1 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones(a)redhat.com>
Date: Thu, 8 Oct 2015 11:11:10 +0100
Subject: [PATCH] qemu: Don't prevent core dump of auto-destroy domain.
---
src/qemu/qemu_driver.c | 8 ++++----
src/qemu/qemu_migration.c | 16 +++++++++-------
src/qemu/qemu_migration.h | 2 +-
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8cd5ee3..c3778de 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3184,7 +3184,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
- if (!qemuMigrationIsAllowed(driver, vm, false, 0))
+ if (!qemuMigrationIsAllowed(driver, vm, false, false, 0))
goto cleanup;
if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE) < 0)
@@ -3616,7 +3616,7 @@ doCoreDump(virQEMUDriverPtr driver,
goto cleanup;
}
- if (!qemuMigrationIsAllowed(driver, vm, false, 0))
+ if (!qemuMigrationIsAllowed(driver, vm, false, true, 0))
goto cleanup;
ret = qemuMigrationToFile(driver, vm, fd, 0, path,
@@ -13690,7 +13690,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
bool resume = false;
int ret = -1;
- if (!qemuMigrationIsAllowed(driver, vm, false, 0))
+ if (!qemuMigrationIsAllowed(driver, vm, false, false, 0))
goto cleanup;
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
@@ -14505,7 +14505,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
/* do the memory snapshot if necessary */
if (memory) {
/* check if migration is possible */
- if (!qemuMigrationIsAllowed(driver, vm, false, 0))
+ if (!qemuMigrationIsAllowed(driver, vm, false, false, 0))
goto cleanup;
/* allow the migration job to be cancelled or the domain to be paused */
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d0f1e46..19031f9 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2201,7 +2201,7 @@ qemuMigrationIsAllowedHostdev(const virDomainDef *def)
bool
qemuMigrationIsAllowed(virQEMUDriverPtr driver,
virDomainObjPtr vm,
- bool remote,
+ bool remote, bool coreDump,
unsigned int flags)
{
int nsnapshots;
@@ -2235,10 +2235,12 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver,
/* following checks don't make sense for offline migration */
if (!(flags & VIR_MIGRATE_OFFLINE)) {
- if (qemuProcessAutoDestroyActive(driver, vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is marked for auto
destroy"));
- return false;
+ if (!coreDump) {
+ if (qemuProcessAutoDestroyActive(driver, vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is marked for auto
destroy"));
+ return false;
+ }
}
@@ -2987,7 +2989,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_BEGIN3);
- if (!qemuMigrationIsAllowed(driver, vm, true, flags))
+ if (!qemuMigrationIsAllowed(driver, vm, true, false, flags))
goto cleanup;
if (!(flags & VIR_MIGRATE_UNSAFE) &&
@@ -5347,7 +5349,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
goto endjob;
}
- if (!qemuMigrationIsAllowed(driver, vm, true, flags))
+ if (!qemuMigrationIsAllowed(driver, vm, true, false, flags))
goto endjob;
if (!(flags & VIR_MIGRATE_UNSAFE) &&
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 8175f4b..cc4d25d 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -174,7 +174,7 @@ int qemuMigrationConfirm(virConnectPtr conn,
int cancelled);
bool qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
- bool remote, unsigned int flags);
+ bool remote, bool coreDump, unsigned int flags);
int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
int fd, off_t offset, const char *path,
--
2.5.3
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v