'continue' the loop if the device is not a disk. Saving the level makes
one of the error messages fit on a single line.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 73 +++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1a80aa4c69..c8f721b00d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6501,49 +6501,48 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriverPtr driver,
for (i = 0; i < ndisks; i++) {
g_autoptr(virCommand) cmd = virCommandNewArgList(qemuimgbin,
"snapshot",
op, name, NULL);
+ int format = virDomainDiskGetFormat(def->disks[i]);
/* FIXME: we also need to handle LVM here */
- if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
- int format = virDomainDiskGetFormat(def->disks[i]);
+ if (def->disks[i]->device != VIR_DOMAIN_DISK_DEVICE_DISK)
+ continue;
- if (format > 0 && format != VIR_STORAGE_FILE_QCOW2) {
- if (try_all) {
- /* Continue on even in the face of error, since other
- * disks in this VM may have the same snapshot name.
- */
- VIR_WARN("skipping snapshot action on %s",
- def->disks[i]->dst);
- skipped = true;
- continue;
- } else if (STREQ(op, "-c") && i) {
- /* We must roll back partial creation by deleting
- * all earlier snapshots. */
- qemuDomainSnapshotForEachQcow2Raw(driver, def, name,
- "-d", false, i);
- }
- virReportError(VIR_ERR_OPERATION_INVALID,
- _("Disk device '%s' does not support"
- " snapshotting"),
- def->disks[i]->dst);
- return -1;
+ if (format > 0 && format != VIR_STORAGE_FILE_QCOW2) {
+ if (try_all) {
+ /* Continue on even in the face of error, since other
+ * disks in this VM may have the same snapshot name.
+ */
+ VIR_WARN("skipping snapshot action on %s",
+ def->disks[i]->dst);
+ skipped = true;
+ continue;
+ } else if (STREQ(op, "-c") && i) {
+ /* We must roll back partial creation by deleting
+ * all earlier snapshots. */
+ qemuDomainSnapshotForEachQcow2Raw(driver, def, name,
+ "-d", false, i);
}
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("Disk device '%s' does not support
snapshotting"),
+ def->disks[i]->dst);
+ return -1;
+ }
- virCommandAddArg(cmd, virDomainDiskGetSource(def->disks[i]));
-
- if (virCommandRun(cmd, NULL) < 0) {
- if (try_all) {
- VIR_WARN("skipping snapshot action on %s",
- def->disks[i]->dst);
- skipped = true;
- continue;
- } else if (STREQ(op, "-c") && i) {
- /* We must roll back partial creation by deleting
- * all earlier snapshots. */
- qemuDomainSnapshotForEachQcow2Raw(driver, def, name,
- "-d", false, i);
- }
- return -1;
+ virCommandAddArg(cmd, virDomainDiskGetSource(def->disks[i]));
+
+ if (virCommandRun(cmd, NULL) < 0) {
+ if (try_all) {
+ VIR_WARN("skipping snapshot action on %s",
+ def->disks[i]->dst);
+ skipped = true;
+ continue;
+ } else if (STREQ(op, "-c") && i) {
+ /* We must roll back partial creation by deleting
+ * all earlier snapshots. */
+ qemuDomainSnapshotForEachQcow2Raw(driver, def, name,
+ "-d", false, i);
}
+ return -1;
}
}
--
2.28.0