diff -Nru libvirt-1.3.1/debian/changelog libvirt-1.3.1/debian/changelog --- libvirt-1.3.1/debian/changelog 2017-12-15 23:21:38.000000000 +0900 +++ libvirt-1.3.1/debian/changelog 2018-02-01 10:13:43.000000000 +0900 @@ -1,3 +1,15 @@ +libvirt (1.3.1-1ubuntu10.16~cloud0) trusty-mitaka; urgency=medium + + * virsh api is stuck when vm is down with NFS borken (LP: #1746630) + - d/p/0001-qemu-driver-Remove-unnecessary-flag-in-qemuDomainGet.patch + qemu: driver: Remove unnecessary flag in qemuDomainGetStatsBlock + - d/p/0002-qemu-driver-Separate-bulk-stats-worker-for-block-dev.patch + qemu: driver: Separate bulk stats worker for block devices + - d/p/0003-qemu-bulk-stats-Don-t-access-possibly-blocked-storag.patch + qemu: bulk stats: Don't access possibly blocked storage + + -- Seyeong Kim Thu, 01 Feb 2018 10:13:06 +0900 + libvirt (1.3.1-1ubuntu10.15~cloud0) trusty-mitaka; urgency=medium * New update for the Ubuntu Cloud Archive. diff -Nru libvirt-1.3.1/debian/patches/0001-qemu-driver-Remove-unnecessary-flag-in-qemuDomainGet.patch libvirt-1.3.1/debian/patches/0001-qemu-driver-Remove-unnecessary-flag-in-qemuDomainGet.patch --- libvirt-1.3.1/debian/patches/0001-qemu-driver-Remove-unnecessary-flag-in-qemuDomainGet.patch 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-1.3.1/debian/patches/0001-qemu-driver-Remove-unnecessary-flag-in-qemuDomainGet.patch 2018-02-01 10:14:57.000000000 +0900 @@ -0,0 +1,74 @@ +From fc6b75e3b028403b53f3421d089bb469690686ba Mon Sep 17 00:00:00 2001 +From: Peter Krempa +Date: Wed, 18 May 2016 14:17:07 +0200 +Subject: [PATCH 1/3] qemu: driver: Remove unnecessary flag in + qemuDomainGetStatsBlock + +'abbreviated' was true if 'stats' were NULL +--- + src/qemu/qemu_driver.c | 15 +++++---------- + 1 file changed, 5 insertions(+), 10 deletions(-) + +Bug: upstream, https://libvirt.org/git/?p=libvirt.git;a=commit;h=5d2b0e6f12b4e57d75ed1047ab1c36443b7a54b3 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1746630 +Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=1337073 +Index: libvirt-1.3.1/src/qemu/qemu_driver.c +=================================================================== +--- libvirt-1.3.1.orig/src/qemu/qemu_driver.c 2018-02-01 10:10:38.637987584 +0900 ++++ libvirt-1.3.1/src/qemu/qemu_driver.c 2018-02-01 10:14:41.000000000 +0900 +@@ -19238,7 +19238,6 @@ + virStorageSourcePtr src, + size_t block_idx, + unsigned int backing_idx, +- bool abbreviated, + virHashTablePtr stats) + { + qemuBlockStats *entry; +@@ -19257,7 +19256,7 @@ + QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex", + backing_idx); + +- if (abbreviated || !alias || !(entry = virHashLookup(stats, alias))) { ++ if (!stats || !alias || !(entry = virHashLookup(stats, alias))) { + if (virStorageSourceIsEmpty(src)) { + ret = 0; + goto cleanup; +@@ -19334,15 +19333,12 @@ + int rc; + virHashTablePtr stats = NULL; + qemuDomainObjPrivatePtr priv = dom->privateData; +- bool abbreviated = false; + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + int count_index = -1; + size_t visited = 0; + bool visitBacking = !!(privflags & QEMU_DOMAIN_STATS_BACKING); + +- if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) { +- abbreviated = true; /* it's ok, just go ahead silently */ +- } else { ++ if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) { + qemuDomainObjEnterMonitor(driver, dom); + rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats, + visitBacking); +@@ -19352,10 +19348,9 @@ + if (qemuDomainObjExitMonitor(driver, dom) < 0) + goto cleanup; + +- if (rc < 0) { ++ /* failure to retrieve stats is fine at this point */ ++ if (rc < 0) + virResetLastError(); +- abbreviated = true; /* still ok, again go ahead silently */ +- } + } + + /* When listing backing chains, it's easier to fix up the count +@@ -19372,7 +19367,7 @@ + while (src && (backing_idx == 0 || visitBacking)) { + if (qemuDomainGetStatsOneBlock(driver, cfg, dom, record, maxparams, + disk, src, visited, backing_idx, +- abbreviated, stats) < 0) ++ stats) < 0) + goto cleanup; + visited++; + backing_idx++; diff -Nru libvirt-1.3.1/debian/patches/0002-qemu-driver-Separate-bulk-stats-worker-for-block-dev.patch libvirt-1.3.1/debian/patches/0002-qemu-driver-Separate-bulk-stats-worker-for-block-dev.patch --- libvirt-1.3.1/debian/patches/0002-qemu-driver-Separate-bulk-stats-worker-for-block-dev.patch 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-1.3.1/debian/patches/0002-qemu-driver-Separate-bulk-stats-worker-for-block-dev.patch 2018-02-01 10:14:39.000000000 +0900 @@ -0,0 +1,92 @@ +From 96cc5154e85f2718011fed7c40c66182fd7cfdee Mon Sep 17 00:00:00 2001 +From: Peter Krempa +Date: Wed, 18 May 2016 14:40:10 +0200 +Subject: [PATCH 2/3] qemu: driver: Separate bulk stats worker for block + devices + +Extract the fallback path that reloads the stats from disk into a +separate function. +--- + src/qemu/qemu_driver.c | 58 ++++++++++++++++++++++++++++++++------------------ + 1 file changed, 37 insertions(+), 21 deletions(-) + +Bug: upstream, https://libvirt.org/git/?p=libvirt.git;a=commit;h=3aa5d51a9530a8737ca584b393c29297dd9bbc37 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1746630 +Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=1337073 +Index: libvirt-1.3.1/src/qemu/qemu_driver.c +=================================================================== +--- libvirt-1.3.1.orig/src/qemu/qemu_driver.c 2018-02-01 10:10:39.861977223 +0900 ++++ libvirt-1.3.1/src/qemu/qemu_driver.c 2018-02-01 10:14:16.000000000 +0900 +@@ -19227,6 +19227,40 @@ + goto cleanup; \ + } while (0) + ++/* refresh information by opening images on the disk */ ++static int ++qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver, ++ virQEMUDriverConfigPtr cfg, ++ virDomainObjPtr dom, ++ virDomainStatsRecordPtr record, ++ int *maxparams, ++ virStorageSourcePtr src, ++ size_t block_idx) ++{ ++ int ret = -1; ++ ++ if (virStorageSourceIsEmpty(src)) ++ return 0; ++ ++ if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) { ++ virResetLastError(); ++ return 0; ++ } ++ ++ if (src->allocation) ++ QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, ++ "allocation", src->allocation); ++ if (src->capacity) ++ QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, ++ "capacity", src->capacity); ++ if (src->physical) ++ QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, ++ "physical", src->physical); ++ ret = 0; ++ cleanup: ++ return ret; ++} ++ + + static int + qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, +@@ -19256,28 +19290,10 @@ + QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex", + backing_idx); + ++ /* use fallback path if data is not available */ + if (!stats || !alias || !(entry = virHashLookup(stats, alias))) { +- if (virStorageSourceIsEmpty(src)) { +- ret = 0; +- goto cleanup; +- } +- +- if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) { +- virResetLastError(); +- ret = 0; +- goto cleanup; +- } +- +- if (src->allocation) +- QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, +- "allocation", src->allocation); +- if (src->capacity) +- QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, +- "capacity", src->capacity); +- if (src->physical) +- QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, +- "physical", src->physical); +- ret = 0; ++ ret = qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, record, ++ maxparams, src, block_idx); + goto cleanup; + } + diff -Nru libvirt-1.3.1/debian/patches/0003-qemu-bulk-stats-Don-t-access-possibly-blocked-storag.patch libvirt-1.3.1/debian/patches/0003-qemu-bulk-stats-Don-t-access-possibly-blocked-storag.patch --- libvirt-1.3.1/debian/patches/0003-qemu-bulk-stats-Don-t-access-possibly-blocked-storag.patch 1970-01-01 09:00:00.000000000 +0900 +++ libvirt-1.3.1/debian/patches/0003-qemu-bulk-stats-Don-t-access-possibly-blocked-storag.patch 2018-02-01 10:14:11.000000000 +0900 @@ -0,0 +1,53 @@ +From 4cd3b0887ad41f7b4e55b522d87811a34468562b Mon Sep 17 00:00:00 2001 +From: Peter Krempa +Date: Wed, 18 May 2016 14:58:25 +0200 +Subject: [PATCH 3/3] qemu: bulk stats: Don't access possibly blocked storage + +If the stats for a block device can't be acquired from qemu we've +fallen back to loading them from the file on the disk in libvirt. + +If qemu is not cooperating due to being stuck on an inaccessible NFS +share we would then attempt to read the files and get stuck too with +the VM object locked. All other APIs would eventually get stuck waiting +on the VM lock. + +Avoid this problem by skipping the block stats if the VM is online but +the monitor did not provide any stats. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337073 +--- + src/qemu/qemu_driver.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +Bug: upstream, https://libvirt.org/git/?p=libvirt.git;a=commit;h=71d2c172edb997bae1e883b2e1bafa97d9f953a1 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1746630 +Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=1337073 +Index: libvirt-1.3.1/src/qemu/qemu_driver.c +=================================================================== +--- libvirt-1.3.1.orig/src/qemu/qemu_driver.c 2018-02-01 10:10:41.057967139 +0900 ++++ libvirt-1.3.1/src/qemu/qemu_driver.c 2018-02-01 10:10:41.053967173 +0900 +@@ -19290,13 +19290,22 @@ + QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex", + backing_idx); + +- /* use fallback path if data is not available */ +- if (!stats || !alias || !(entry = virHashLookup(stats, alias))) { ++ /* the VM is offline so we have to go and load the stast from the disk by ++ * ourselves */ ++ if (!virDomainObjIsActive(dom)) { + ret = qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, record, + maxparams, src, block_idx); + goto cleanup; + } + ++ /* In case where qemu didn't provide the stats we stop here rather than ++ * trying to refresh the stats from the disk. Inability to provide stats is ++ * usually caused by blocked storage so this would make libvirtd hang */ ++ if (!stats || !alias || !(entry = virHashLookup(stats, alias))) { ++ ret = 0; ++ goto cleanup; ++ } ++ + QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, + "rd.reqs", entry->rd_req); + QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, diff -Nru libvirt-1.3.1/debian/patches/series libvirt-1.3.1/debian/patches/series --- libvirt-1.3.1/debian/patches/series 2017-11-07 00:35:57.000000000 +0900 +++ libvirt-1.3.1/debian/patches/series 2018-02-01 10:10:34.000000000 +0900 @@ -81,3 +81,6 @@ ubuntu/bug-1705132-qemu-Adaptive-timeout-for-connecting-to-monitor.patch ubuntu/bug-1708305-qemu-Fix-memory-locking-limit-calculation.patch storage-Don-t-pass-iso-format-to-qemu-img.patch +0001-qemu-driver-Remove-unnecessary-flag-in-qemuDomainGet.patch +0002-qemu-driver-Separate-bulk-stats-worker-for-block-dev.patch +0003-qemu-bulk-stats-Don-t-access-possibly-blocked-storag.patch