[libvirt] [PATCH 0/6] Ensure clean compile with clang
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
There are various problems building libvirt with clang,
which mostly revolve around compiler warning handling.
This series fixes all the problems I see with clang
3.2 on a Fedora 19 x86_64 host.
Daniel P. Berrange (6):
Ensure consistent enablement of gcc 'diagnostic' pragma
Workaround issue with clang and inline functions with static vars
Ignore cast alignment warnings in inotify code for Xen.
Correctly detect warning flags with clang
Only pass -export-dynamic to linker, not compiler
Don't duplicate compiler warning flags when linking
configure.ac | 4 ++--
daemon/Makefile.am | 1 -
m4/virt-compile-warnings.m4 | 29 +++++++++++++++++++++++++----
src/Makefile.am | 11 +++--------
src/internal.h | 2 +-
src/xen/xen_inotify.c | 3 +++
tests/vircgroupmock.c | 7 ++++++-
tools/Makefile.am | 4 +---
8 files changed, 41 insertions(+), 20 deletions(-)
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCH] tests: Add fchostdata in EXTRA_DIST
by Osier Yang
Pushed under build-breaker rule.
---
tests/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f53e208..2822d39 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -86,7 +86,8 @@ EXTRA_DIST = \
xmconfigdata \
xml2sexprdata \
xml2vmxdata \
- .valgrind.supp
+ .valgrind.supp \
+ fchostdata
test_helpers = commandhelper ssh test_conf
test_programs = virshtest sockettest \
--
1.8.1.4
11 years, 6 months
[libvirt] [libvirt PATCH 0/2] qemu: disable memory merge at guest startup
by Osier Yang
*** BLURB HERE ***
Eric Blake (1):
qemu: detect -machine mem-merge capability
Osier Yang (1):
qemu: New XML to disable memory merge at guest startup
docs/formatdomain.html.in | 13 +++++---
docs/schemas/domaincommon.rng | 5 +++
src/conf/domain_conf.c | 20 ++++++++----
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 37 ++++++++++++++++++++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 22 +++++++++++++
tests/qemuargv2xmltest.c | 2 ++
.../qemuxml2argv-nosharepages.args | 4 +++
.../qemuxml2argvdata/qemuxml2argv-nosharepages.xml | 31 ++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmltest.c | 1 +
12 files changed, 128 insertions(+), 10 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-nosharepages.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-nosharepages.xml
--
1.8.1.4
11 years, 6 months
[libvirt] [libvirt-tck PATCH v2 1/3] add three APIs testing for block
by Zhe Peng
new script for block APIs
dom->block_resize
dom->get_block_info
dom->block_peek
---
scripts/domain/121-block-info.t | 137 +++++++++++++++++++++++++++++++++++++++
1 files changed, 137 insertions(+), 0 deletions(-)
create mode 100644 scripts/domain/121-block-info.t
diff --git a/scripts/domain/121-block-info.t b/scripts/domain/121-block-info.t
new file mode 100644
index 0000000..17ebb2e
--- /dev/null
+++ b/scripts/domain/121-block-info.t
@@ -0,0 +1,137 @@
+# -*- perl -*-
+#
+# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013 Zhe Peng <zpeng(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
+
+domain/121-block-info.t
+
+=head1 DESCRIPTION
+
+The test case validates that all following APIs work well include
+dom->block_resize
+dom->get_block_info
+dom->block_peek
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 29;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::stat;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+}
+
+# test is_alive
+my $live = $conn->is_alive();
+ok($live > 0, "Connection is alive");
+
+my $xml = $tck->generic_pool("dir")->as_xml;
+
+diag "Defining transient storage pool";
+my $pool;
+ok_pool(sub { $pool = $conn->define_storage_pool($xml) }, "define transient storage pool");
+lives_ok(sub { $pool->build(0) }, "built storage pool");
+lives_ok(sub { $pool->create }, "started storage pool");
+
+my $volallocxml = $tck->generic_volume("tck", "raw", 1024*1024*50)->allocation(1024*1024*50)->as_xml;
+my ($vol, $path, $st);
+ok_volume { $vol = $pool->create_volume($volallocxml) } "create fully allocated raw volume";
+
+my $volallocxml2 = $tck->generic_volume("tck2", "raw", 1024*1024*50)->allocation(1024*1024)->as_xml;
+my ($vol2, $path2, $st2);
+ok_volume { $vol2 = $pool->create_volume($volallocxml2) } "create not fully allocated raw volume";
+
+my $volallocxml3 = $tck->generic_volume("tck3", "qcow2", 1024*1024*50)->allocation(1024*1024)->as_xml;
+my ($vol3, $path3, $st3);
+ok_volume { $vol3 = $pool->create_volume($volallocxml3) } "create qcow2 volume";
+
+$path = xpath($vol, "string(/volume/target/path)");
+$st = stat($path);
+ok($st, "path $path exists");
+is($st->size, 1024*1024*50, "size is 50M");
+
+$path2 = xpath($vol2, "string(/volume/target/path)");
+$st2 = stat($path2);
+ok($st2, "path $path2 exists");
+
+$path3 = xpath($vol3, "string(/volume/target/path)");
+$st3 = stat($path3);
+ok($st3, "path $path3 exists");
+
+diag "Generic guest with pervious created vol";
+my $disktype = "raw";
+my $dst = "vda";
+my $dst2 = "vdb";
+my $dst3 = "vdc";
+my $guest = $tck->generic_domain("tck");
+$guest->rmdisk();
+
+$guest->disk(format => { name => "qemu", type => $disktype }, type => "file", src => $path, dst => $dst);
+$guest->disk(format => { name => "qemu", type => $disktype }, type => "file", src=> $path2, dst => $dst2);
+$guest->disk(format => { name => "qemu", type => "qcow2" }, type => "file", src=> $path3, dst => $dst3);
+$guest->interface(type => "network", source => "default", model => "virtio", mac => "52:54:00:22:22:22");
+
+$xml = $guest->as_xml;
+my $dom;
+ok_domain(sub { $dom = $conn->create_domain($xml) }, "Create domain");
+$xml = $dom->get_xml_description();
+
+is($dom->get_block_info($dst2,0)->{capacity}, 1024*1024*50, "Get disk capacity info");
+is($dom->get_block_info($dst2,0)->{allocation}, 1024*1024, "Get disk allocation info");
+is($dom->get_block_info($dst2,0)->{physical}, 1024*1024, "Get disk physical info");
+
+
+is($dom->get_block_info($dst,0)->{capacity}, 1024*1024*50, "Get disk capacity info");
+is($dom->get_block_info($dst,0)->{allocation}, 1024*1024*50, "Get disk allocation info");
+is($dom->get_block_info($dst,0)->{physical}, 1024*1024*50, "Get disk physical info");
+
+diag "Test block_resize";
+lives_ok(sub {$dom->block_resize($dst, 512*50)}, "resize to 512*50 KB");
+$st = stat($path);
+is($st->size, 512*1024*50, "size is 25M");
+
+is($dom->get_block_info($dst,0)->{capacity}, 1024*512*50, "Get disk capacity info");
+is($dom->get_block_info($dst,0)->{allocation}, 1024*512*50, "Get disk allocation info");
+is($dom->get_block_info($dst,0)->{physical}, 1024*512*50, "Get disk physical info");
+
+lives_ok(sub {$dom->block_resize($dst, 1024*50)}, "resize to 1024*50 KB");
+$st = stat($path);
+is($st->size, 1024*1024*50, "size is 50M");
+
+diag "Test block_peek";
+my $date = "test";
+system("echo $date > $path");
+is($dom->block_peek($path,0,4,0), $date, "Get date from raw image");
+
+#qcow2 file start with hexadecimal:0x51 0x46 0x49 (ASCII: "QFI")
+is($dom->block_peek($path3,0,3,0), "QFI", "Get date from qcow2 image");
+
+lives_ok(sub { $vol->delete(0) }, "deleted volume");
+
+diag "Destroy domain";
+$dom->destroy;
+
+ok_error(sub { $conn->get_domain_by_name("tck") }, "NO_DOMAIN error raised from missing domain", 42);
+
--
1.7.7.6
11 years, 6 months
[libvirt] [PATCH] spec: fix outdated comment
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=963016 points out that
we don't use initscripts by default on Fedora any more.
* libvirt.spec.in (Requires): Better explanation of gettext.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the trivial rule.
libvirt.spec.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index f4ec6eb..ad9cea2 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1022,7 +1022,7 @@ Requires: ncurses
# So remote clients can access libvirt over SSH tunnel
# (client invokes 'nc' against the UNIX socket on the server)
Requires: nc
-# Needed by libvirt-guests init script.
+# Needed by /usr/libexec/libvirt-guests.sh script.
Requires: gettext
# Needed by virt-pki-validate script.
Requires: gnutls-utils
--
1.8.1.4
11 years, 6 months
[libvirt] latency between LIFECYCLE event and notification generation
by nishant burte
Hi,
I want to know following about LIFECYCLE events of libvirt.
1. about the the latency of these events happening and notification
generation.
e.g. suppose a VM goes down. How much time it takes to realize that the
particular VM has gone down(going to say, DEFINED state) and then
notification is generated?
2. Second question is, can someone please explain what are the sequence of
steps happen between a VM going down and the notification is generated?
Could you please answer both the queries?
Thanks
Nishant
11 years, 6 months
[libvirt] [PATCH v3] nwfilter: check for inverted ctdir
by Stefan Berger
Linux netfilter at some point (Linux 2.6.39) inverted the meaning of the
'--ctdir reply' and newer netfilter implementations now expect
'--ctdir original' instead and vice-versa.
We check for the kernel version and assume that all Linux kernels with version
2.6.39 have the newer inverted logic.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
v2->v3:
- using uname now to check for Linux kernel version number
v1->v2:
- using virSocketAddrParseIPv4
---
src/nwfilter/nwfilter_ebiptables_driver.c | 54 ++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <sys/utsname.h>
#include "internal.h"
@@ -85,6 +86,17 @@ static char *iptables_cmd_path;
static char *ip6tables_cmd_path;
static char *grep_cmd_path;
+/*
+ * --ctdir original vs. --ctdir reply's meaning was inverted in netfilter
+ * at some point (Linux 2.6.39)
+ */
+enum ctdirStatus {
+ CTDIR_STATUS_UNKNOWN = 0,
+ CTDIR_STATUS_CORRECTED = 1,
+ CTDIR_STATUS_OLD = 2,
+};
+static enum ctdirStatus iptables_ctdir_corrected;
+
#define PRINT_ROOT_CHAIN(buf, prefix, ifname) \
snprintf(buf, sizeof(buf), "libvirt-%c-%s", prefix, ifname)
#define PRINT_CHAIN(buf, prefix, ifname, suffix) \
@@ -1262,6 +1274,17 @@ iptablesEnforceDirection(int directionIn
virNWFilterRuleDefPtr rule,
virBufferPtr buf)
{
+ switch (iptables_ctdir_corrected) {
+ case CTDIR_STATUS_UNKNOWN:
+ /* could not be determined or s.th. is seriously wrong */
+ return;
+ case CTDIR_STATUS_CORRECTED:
+ directionIn = !directionIn;
+ break;
+ case CTDIR_STATUS_OLD:
+ break;
+ }
+
if (rule->tt != VIR_NWFILTER_RULE_DIRECTION_INOUT)
virBufferAsprintf(buf, " -m conntrack --ctdir %s",
(directionIn) ? "Original"
@@ -4304,6 +4327,34 @@ ebiptablesDriverTestCLITools(void)
return ret;
}
+static void
+ebiptablesDriverProbeCtdir(void)
+{
+ struct utsname utsname;
+ unsigned int major, minor, micro;
+
+ iptables_ctdir_corrected = CTDIR_STATUS_UNKNOWN;
+
+ if (uname(&utsname) < 0) {
+ VIR_ERROR(_("Call to utsname failed: %d"), errno);
+ return;
+ }
+
+ /* following Linux lxr, the logic was inverted in 2.6.39 */
+ if (sscanf(utsname.release, "%u.%u.%u", &major, &minor, µ) != 3) {
+ VIR_ERROR(_("Could not detect kernel version from string %s"),
+ utsname.release);
+ return;
+ }
+
+ if (major >= 3 ||
+ (major == 2 && minor == 6 && micro >= 39))
+ iptables_ctdir_corrected = CTDIR_STATUS_CORRECTED;
+ else
+ iptables_ctdir_corrected = CTDIR_STATUS_OLD;
+
+}
+
static int
ebiptablesDriverInit(bool privileged)
{
@@ -4341,6 +4392,9 @@ ebiptablesDriverInit(bool privileged)
return -ENOTSUP;
}
+ if (iptables_cmd_path)
+ ebiptablesDriverProbeCtdir();
+
ebiptables_driver.flags = TECHDRV_FLAG_INITIALIZED;
return 0;
11 years, 6 months
[libvirt] [PATCH 0/7] util: Fixes for NPIV related helpers
by Osier Yang
Osier Yang (7):
util: Fix regression of wwn reading
util: Fix regression introduced by commit 4360a098441
util: Don't miss the slash in constructed path
util: Change virIsCapable* to return bool
util: Update the comment for virGetFCHostNameByWWN
util: Honor the passed sysfs_prefix
tests: Add tests for fc_host
src/node_device/node_device_linux_sysfs.c | 4 +-
src/util/virutil.c | 47 +++---
src/util/virutil.h | 4 +-
tests/Makefile.am | 5 +
tests/fchostdata/fc_host/host4/fabric_name | 1 +
tests/fchostdata/fc_host/host4/max_npiv_vports | 1 +
tests/fchostdata/fc_host/host4/node_name | 1 +
tests/fchostdata/fc_host/host4/npiv_vports_inuse | 1 +
tests/fchostdata/fc_host/host4/port_name | 1 +
tests/fchostdata/fc_host/host4/port_state | 1 +
tests/fchostdata/fc_host/host4/vport_create | 0
tests/fchostdata/fc_host/host4/vport_delete | 0
tests/fchostdata/fc_host/host5/fabric_name | 1 +
tests/fchostdata/fc_host/host5/max_npiv_vports | 1 +
tests/fchostdata/fc_host/host5/node_name | 1 +
tests/fchostdata/fc_host/host5/npiv_vports_inuse | 1 +
tests/fchostdata/fc_host/host5/port_name | 1 +
tests/fchostdata/fc_host/host5/port_state | 1 +
tests/fchostdata/fc_host/host5/vport_create | 0
tests/fchostdata/fc_host/host5/vport_delete | 0
tests/fchosttest.c | 175 +++++++++++++++++++++++
21 files changed, 220 insertions(+), 27 deletions(-)
create mode 100644 tests/fchostdata/fc_host/host4/fabric_name
create mode 100644 tests/fchostdata/fc_host/host4/max_npiv_vports
create mode 100644 tests/fchostdata/fc_host/host4/node_name
create mode 100644 tests/fchostdata/fc_host/host4/npiv_vports_inuse
create mode 100644 tests/fchostdata/fc_host/host4/port_name
create mode 100644 tests/fchostdata/fc_host/host4/port_state
create mode 100644 tests/fchostdata/fc_host/host4/vport_create
create mode 100644 tests/fchostdata/fc_host/host4/vport_delete
create mode 100644 tests/fchostdata/fc_host/host5/fabric_name
create mode 100644 tests/fchostdata/fc_host/host5/max_npiv_vports
create mode 100644 tests/fchostdata/fc_host/host5/node_name
create mode 100644 tests/fchostdata/fc_host/host5/npiv_vports_inuse
create mode 100644 tests/fchostdata/fc_host/host5/port_name
create mode 100644 tests/fchostdata/fc_host/host5/port_state
create mode 100644 tests/fchostdata/fc_host/host5/vport_create
create mode 100644 tests/fchostdata/fc_host/host5/vport_delete
create mode 100644 tests/fchosttest.c
--
1.8.1.4
11 years, 6 months
[libvirt] [PATCH] Forbid use of ':' in RBD pool names
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The QEMU command line syntax for RBD disks is
file=rbd:pool/image:opt1=val1:opt2=val2...
There is no way to escape the ':' if it appears in the
pool or image name. Thus it must be explicitly forbidden
if it occurs in the libvirt XML. People are known to
be abusing the lack of escaping in current libvirt to
pass arbitrary args to QEMU.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_command.c | 6 ++++
...qemuxml2argv-disk-drive-network-rbd-invalid.xml | 37 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 5 +++
3 files changed, 48 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-invalid.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index eddc263..c0cb250 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2383,6 +2383,12 @@ qemuBuildRBDString(virConnectPtr conn,
char *secret = NULL;
size_t secret_size;
+ if (strchr(disk->src, ':')) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("':' not allowed in RBD source volume name"));
+ return -1;
+ }
+
virBufferEscape(opt, ',', ",", "rbd:%s", disk->src);
if (disk->auth.username) {
virBufferEscape(opt, '\\', ":", ":id=%s", disk->auth.username);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-invalid.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-invalid.xml
new file mode 100644
index 0000000..e8d3280
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-invalid.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='rbd' name='poolname/imagename:rbd_cache=1:rbd_cache_size=67108864:rbd_cache_max_dirty=0'>
+ <host name='mon1.example.org' port='6321'/>
+ <host name='mon2.example.org' port='6322'/>
+ <host name='mon3.example.org' port='6322'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 98ceb83..579c016 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -160,6 +160,9 @@ static int testCompareXMLToArgvFiles(const char *xml,
VIR_NETDEV_VPORT_PROFILE_OP_NO_OP))) {
if (flags & FLAG_EXPECT_FAILURE) {
ret = 0;
+ if (virTestGetDebug() > 1)
+ fprintf(stderr, "Got expected error: %s\n",
+ virGetLastErrorMessage());
virResetLastError();
}
goto out;
@@ -528,6 +531,8 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-network-rbd-ipv6",
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
+ DO_TEST_FAILURE("disk-drive-network-rbd-invalid",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-no-boot",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_BOOTINDEX);
DO_TEST("disk-usb", NONE);
--
1.8.2.1
11 years, 6 months
[libvirt] [PATCHv2] storage: Ensure 'qemu-img resize' size arg is a 512 multiple
by Christophe Fergeau
qemu-img resize will fail with "The new size must be a multiple of 512"
if libvirt doesn't round it first.
This fixes rhbz#951495
Signed-off-by: Christophe Fergeau <cfergeau(a)redhat.com>
---
Changes since v1:
- move rounding code to a new VIR_ROUND_UP() macro
- add a note in virStorageVolResize API doc that the
requested capacity may be rounded up
src/internal.h | 3 +++
src/libvirt.c | 3 ++-
src/storage/storage_backend_fs.c | 4 ++++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/internal.h b/src/internal.h
index d819aa3..28540f4 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -339,6 +339,9 @@
/* divide value by size, rounding up */
# define VIR_DIV_UP(value, size) (((value) + (size) - 1) / (size))
+/* round up value to the closest multiple of size */
+# define VIR_ROUND_UP(value, size) (VIR_DIV_UP(value, size) * (size))
+
# if WITH_DTRACE_PROBES
# ifndef LIBVIRT_PROBES_H
diff --git a/src/libvirt.c b/src/libvirt.c
index 2b3515e..f2360f8 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -14124,7 +14124,8 @@ error:
* Changes the capacity of the storage volume @vol to @capacity. The
* operation will fail if the new capacity requires allocation that would
* exceed the remaining free space in the parent pool. The contents of
- * the new capacity will appear as all zero bytes.
+ * the new capacity will appear as all zero bytes. The capacity value will
+ * be rounded to the granularity supported by the hypervisor.
*
* Normally, the operation will attempt to affect capacity with a minimum
* impact on allocation (that is, the default operation favors a sparse
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 9b83e57..1379f17 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1219,6 +1219,10 @@ virStorageBackendFilesystemResizeQemuImg(const char *path,
return -1;
}
+ /* Round capacity as qemu-img resize errors out on sizes which are not
+ * a multiple of 512 */
+ capacity = VIR_ROUND_UP(capacity, 512);
+
cmd = virCommandNew(img_tool);
virCommandAddArgList(cmd, "resize", path, NULL);
virCommandAddArgFormat(cmd, "%llu", capacity);
--
1.8.2.1
11 years, 6 months