[libvirt] [PATCH v2] storage: Check stderr when matching parted output
by Hao Liu
In old version of parted like parted-2.1-25, error message is shown in
stdout when printing a disk info without disk label.
Error: /dev/sda: unrecognised disk label
This line has been moved to stderr in newer version of parted. So we
should check both stdout and stderr when locating this message.
This should fix bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1172468
Signed-off-by: Hao Liu <hliu(a)redhat.com>
---
V2: (Courtesy of Luyang Huang)
Fixed memory leak;
Fixed curly brace style;
src/storage/storage_backend_disk.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 4b05e8c..3f97fd9 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -370,21 +370,26 @@ virStorageBackendDiskFindLabel(const char* device)
};
virCommandPtr cmd = virCommandNew(PARTED);
char *output = NULL;
+ char *error = NULL;
int ret = -1;
virCommandAddArgSet(cmd, args);
virCommandAddEnvString(cmd, "LC_ALL=C");
virCommandSetOutputBuffer(cmd, &output);
+ virCommandSetErrorBuffer(cmd, &error);
/* if parted succeeds we have a valid partition table */
ret = virCommandRun(cmd, NULL);
if (ret < 0) {
- if (strstr(output, "unrecognised disk label"))
+ if (strstr(output, "unrecognised disk label") ||
+ strstr(error, "unrecognised disk label")) {
ret = 1;
+ }
}
virCommandFree(cmd);
VIR_FREE(output);
+ VIR_FREE(error);
return ret;
}
--
1.8.3.1
9 years, 11 months
[libvirt] [PATCH] maint: clean up the unused variable 'caps' in src/qemu/qemu_*.c
by Wang Rui
Signed-off-by: Wang Rui <moon.wangrui(a)huawei.com>
---
src/qemu/qemu_driver.c | 9 ---------
src/qemu/qemu_hotplug.c | 5 -----
2 files changed, 14 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index be37c8f..3406385 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1864,7 +1864,6 @@ static int qemuDomainResume(virDomainPtr dom)
virObjectEventPtr event = NULL;
int state;
virQEMUDriverConfigPtr cfg = NULL;
- virCapsPtr caps = NULL;
if (!(vm = qemuDomObjFromDomain(dom)))
return -1;
@@ -1901,8 +1900,6 @@ static int qemuDomainResume(virDomainPtr dom)
VIR_DOMAIN_EVENT_RESUMED,
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
}
- if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto endjob;
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
goto endjob;
ret = 0;
@@ -1916,7 +1913,6 @@ static int qemuDomainResume(virDomainPtr dom)
virObjectUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
- virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
}
@@ -7108,7 +7104,6 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn,
{
virDomainDiskDefPtr disk = dev->data.disk;
virDomainDiskDefPtr orig_disk = NULL;
- virCapsPtr caps = NULL;
int ret = -1;
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
@@ -7129,9 +7124,6 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn,
goto end;
}
- if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto end;
-
/* Add the new disk src into shared disk hash table */
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
goto end;
@@ -7154,7 +7146,6 @@ qemuDomainChangeDiskMediaLive(virConnectPtr conn,
}
end:
- virObjectUnref(caps);
return ret;
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0d97b57..9530451 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -758,7 +758,6 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
{
virDomainDiskDefPtr disk = dev->data.disk;
virDomainDiskDefPtr orig_disk = NULL;
- virCapsPtr caps = NULL;
int ret = -1;
const char *driverName = virDomainDiskGetDriver(disk);
const char *src = virDomainDiskGetSource(disk);
@@ -796,9 +795,6 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
goto end;
}
- if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto end;
-
if (qemuDomainChangeEjectableMedia(driver, conn, vm, orig_disk,
disk->src, false) < 0)
goto end;
@@ -837,7 +833,6 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
end:
if (ret != 0)
ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name));
- virObjectUnref(caps);
return ret;
}
--
1.7.12.4
9 years, 11 months
[libvirt] [PATCH v2] docs: Fix missing curly braces
by Hao Liu
Signed-off-by: Hao Liu <hliu(a)redhat.com>
---
docs/hacking.html.in | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index a73b1e0..53786b7 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -481,8 +481,9 @@
<pre>
while (expr1 &&
- expr2) // multi-line, at same indentation, {} required
+ expr2) { // multi-line, at same indentation, {} required
single_line_stmt();
+ }
</pre>
<p>
--
1.8.3.1
9 years, 11 months
[libvirt] [PATCH v1 0/3] Forbid negative values in config files
by Michal Privoznik
*** BLURB HERE ***
Michal Privoznik (3):
virConfSetValue: Simplify condition
virConfType: switch to VIR_ENUM_{DECL,IMPL}
virconf: Introduce VIR_CONF_ULONG
daemon/libvirtd-config.c | 55 ++++++++++++++++++++++++---------------
src/libvirt_private.syms | 2 ++
src/locking/lock_daemon_config.c | 24 ++++++++++++-----
src/locking/lock_driver_lockd.c | 4 +--
src/locking/lock_driver_sanlock.c | 6 ++---
src/lxc/lxc_conf.c | 6 ++---
src/qemu/qemu_conf.c | 43 ++++++++++++++++++++----------
src/util/virconf.c | 12 +++++++--
src/util/virconf.h | 29 +++++++--------------
src/xenconfig/xen_common.c | 6 ++---
tests/libvirtdconftest.c | 9 ++++---
11 files changed, 119 insertions(+), 77 deletions(-)
--
2.0.4
9 years, 11 months
[libvirt] [PATCH] util: check for an illegal character in a XML namespace prefix
by Erik Skultety
When user tries to insert element metadata providing a namespace
declaration as well, currently we insert the element without any validation
check for XML prefix (if provided). The next VM start would then
fail with parse error. This patch fixes this issue by adding a call to
xmlValidateNCName function to check for illegal characters in the
prefix.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1143921
---
src/util/virxml.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 7f591fb..93f8590 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1066,6 +1066,12 @@ virXMLInjectNamespace(xmlNodePtr node,
{
xmlNsPtr ns;
+ if (xmlValidateNCName((const unsigned char *)key, 1) != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("failed to validate prefix for a new XML namespace"));
+ return -1;
+ }
+
if (!(ns = xmlNewNs(node, (const unsigned char *)uri, (const unsigned char *)key))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to create a new XML namespace"));
--
1.9.3
9 years, 11 months
[libvirt] [PATCH] docs: Fix missing curly braces
by Hao Liu
Signed-off-by: Hao Liu <hliu(a)redhat.com>
---
HACKING | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/HACKING b/HACKING
index 884e78c..94d9d2c 100644
--- a/HACKING
+++ b/HACKING
@@ -383,8 +383,9 @@ single-'statement' loop: each has only one 'line' in its body.
single_line_stmt(); // {} is optional (not enforced either way)
while (expr1 &&
- expr2) // multi-line, at same indentation, {} required
+ expr2) { // multi-line, at same indentation, {} required
single_line_stmt();
+ }
However, the moment your loop/if/else body extends on to a second line, for
whatever reason (even if it's just an added comment), then you should add
--
1.8.3.1
9 years, 11 months
[libvirt] [PATCH v4 00/15] parallels: rewrite driver with parallels SDK
by Dmitry Guryanov
This patch series replaces all code, which used prlctl command
to interact with parallels cloud server with calls to
parallels sdk functions.
The model of this driver remain almost the same - in creates a
list of virDomainObj objects on connect and then functions, which
returns different information get info from this list.
Changes in v2:
* Rebase to latest libvirt sources
* Use only "parallels" prefix for functions in parallelsDriver,
so that make check will pass
* Update privconn->domains in case we change something from current
connection.
Changes in v3:
* in parallels: get domain info with SDK:
replace
+ case VIR_ARCH_X86_64:
with
+ case PCM_CPU_MODE_64:
Changes in v4:
* handle onReboot, onPoweroff and onCrash properly
* handle disks cache mode
* don't set net interface name if virDomainNetDef.ifname is NULL
* improve error handling
Alexander Burluka (4):
parallels: get domain info with SDK
parallels: handle events from parallels server
parallels: added function virDomainIsActive()
parallels: Add domainCreateWithFlags() function.
Dmitry Guryanov (11):
parallels: move IS_CT macro to parallels_utils.h
parallels: move parallelsDomNotFoundError to parallels_utils.h
parallels: reimplement functions, which change domain state
parallels: rewrite parallelsApplyConfig with SDK
parallels: create VMs and containers with sdk
parallels: refactor parallelsDomainDefineXML
parallels: add cdroms support
parallels: implement domainUndefine and domainUndefineFlags
parallels: return PRL_RESULT from waitJob and getJobResult
parallels: fix getJobResultHelper
parallels: report proper error in Create/Destroy/Suspend e.t.c.
src/parallels/parallels_driver.c | 2456 +++++++-----------------------------
src/parallels/parallels_sdk.c | 2544 +++++++++++++++++++++++++++++++++++++-
src/parallels/parallels_sdk.h | 25 +
src/parallels/parallels_utils.h | 11 +
4 files changed, 3033 insertions(+), 2003 deletions(-)
--
1.9.3
9 years, 11 months
[libvirt] [PATCH] storage: Check stderr when matching parted output
by Hao Liu
In old version of parted like parted-2.1-25, error message is shown in
stdout when printing a disk info without disk label.
Error: /dev/sda: unrecognised disk label
This line has been moved to stderr in newer version of parted. So we
should check both stdout and stderr when locating this message.
This should fix bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1172468
Signed-off-by: Hao Liu <hliu(a)redhat.com>
---
src/storage/storage_backend_disk.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 4b05e8c..d57b67d 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -370,16 +370,19 @@ virStorageBackendDiskFindLabel(const char* device)
};
virCommandPtr cmd = virCommandNew(PARTED);
char *output = NULL;
+ char *error = NULL;
int ret = -1;
virCommandAddArgSet(cmd, args);
virCommandAddEnvString(cmd, "LC_ALL=C");
virCommandSetOutputBuffer(cmd, &output);
+ virCommandSetErrorBuffer(cmd, &error);
/* if parted succeeds we have a valid partition table */
ret = virCommandRun(cmd, NULL);
if (ret < 0) {
- if (strstr(output, "unrecognised disk label"))
+ if (strstr(output, "unrecognised disk label") ||
+ strstr(error, "unrecognised disk label"))
ret = 1;
}
--
1.8.3.1
9 years, 11 months
[libvirt] ANNOUNCE: libguestfs 1.26 released
by Richard W.M. Jones
I'm pleased to announce libguestfs 1.26, a library and set of tools
for accessing and modifying virtual machine disk images. This release
took more than 6 months of work by a considerable number of people,
and has many new features (see release notes below).
You can get libguestfs 1.26 here:
Main website: http://libguestfs.org/
Source: http://libguestfs.org/download/1.26-stable/
You will also need latest supermin from here:
http://libguestfs.org/download/supermin/
Fedora 20/21: http://koji.fedoraproject.org/koji/packageinfo?packageID=8391
It will appear as an update for F20 in about a week.
Debian/experimental coming soon, see:
https://packages.debian.org/experimental/libguestfs0
The Fedora and Debian packages have split dependencies so you can
download just the features you need.
>From http://libguestfs.org/guestfs-release-notes.1.html :
RELEASE NOTES FOR LIBGUESTFS 1.26
New features
Tools
virt-customize(1) is a new tool for customizing virtual machine disk
images. It lets you install packages, edit configuration files, run
scripts, set passwords and so on. virt-builder(1) and virt-sysprep(1)
use virt-customize, and command line options across all these tools are
now identical.
virt-diff(1) is a new tool for showing the differences between the
filesystems of two virtual machines. It is mainly useful when showing
what files have been changed between snapshots.
virt-builder(1) has been greatly enhanced. There are many more ways to
customize the virtual machine. It can pull templates from multiple
repositories. A parallelized internal xzcat implementation speeds up
template decompression. Virt-builder uses an optimizing planner to
choose the fastest way to build the VM. It is now easier to use
virt-builder from other programs. Internationalization support has been
added to metadata. More efficient SELinux relabelling of files. Can
build guests for multiple architectures. Error messages have been
improved. (Pino Toscano)
virt-sparsify(1) has a new --in-place option. This sparsifies an image
in place (without copying it) and is also much faster. (Lots of help
provided by Paolo Bonzini)
virt-sysprep(1) can delete and scrub files under user control. You can
lock user accounts or set random passwords on accounts. Can remove more
log files. Can unsubscribe a guest from Red Hat Subscription Manager.
New flexible way to enable and disable operations. (Wanlong Gao, Pino
Toscano)
virt-win-reg(1) allows you to use URIs to specify remote disk images.
virt-format(1) can now pass the extra space that it recovers back to
the host.
guestfish(1) has additional environment variables to give fine control
over the ><fs> prompt. Guestfish reads its (rarely used) configuration
file in a different order now so that local settings override global
settings. (Pino Toscano)
virt-make-fs(1) was rewritten in C, but is unchanged in terms of
functionality and command line usage.
Language bindings
The OCaml bindings have a new Guestfs.Errno module, used to check the
error number returned by Guestfs.last_errno.
PHP tests now work. (Pino Toscano)
Inspection
Inspection can recognize Debian live images.
Architectures
ARMv7 (32 bit) now supports KVM acceleration.
Aarch64 (ARM 64 bit) is supported, but the appliance part does not work
yet.
PPC64 support has been fixed and enhanced.
Security
Denial of service when inspecting disk images with corrupt btrfs
volumes
It was possible to crash libguestfs (and programs that use libguestfs
as a library) by presenting a disk image containing a corrupt btrfs
volume.
This was caused by a NULL pointer dereference causing a denial of
service, and is not thought to be exploitable any further.
See commit d70ceb4cbea165c960710576efac5a5716055486 for the fix. This
fix is included in libguestfs stable branches ≥ 1.26.0, ≥ 1.24.6 and
≥ 1.22.8, and also in RHEL ≥ 7.0. Earlier versions of libguestfs are
not vulnerable.
Better generation of random root passwords and random seeds
When generating random root passwords and random seeds, two bugs were
fixed which are possibly security related. Firstly we no longer read
excessive bytes from /dev/urandom (most of which were just thrown
away). Secondly we changed the code to avoid modulo bias. These
issues were not thought to be exploitable. (Both changes suggested by
Edwin Török)
API
GUID parameters are now validated when they are passed to API calls,
whereas previously you could have passed any string. (Pino Toscano)
New APIs
guestfs_add_drive_opts: new discard parameter
The new discard parameter allows fine-grained control over
discard/trim support for a particular disk. This allows the host file
to become more sparse (or thin-provisioned) when you delete files or
issue the guestfs_fstrim API call.
guestfs_add_domain: new parameters: cachemode, discard
These parameters are passed through when adding the domain's disks.
guestfs_blkdiscard
Discard all blocks on a guestfs device. Combined with the discard
parameter above, this makes the host file sparse.
guestfs_blkdiscardzeroes
Test if discarded blocks read back as zeroes.
guestfs_compare_*
guestfs_copy_*
For each struct returned through the API, libguestfs now generates
guestfs_compare_* and guestfs_copy_* functions to allow you to
compare and copy structs.
guestfs_copy_attributes
Copy attributes (like permissions, xattrs, ownership) from one file
to another. (Pino Toscano)
guestfs_disk_create
A flexible API for creating empty disk images from scratch. This
avoids the need to call out to external programs like qemu-img(1).
guestfs_get_backend_settings
guestfs_set_backend_settings
Per-backend settings (can also be set via the environment variable
LIBGUESTFS_BACKEND_SETTINGS). The main use for this is forcing TCG
mode in the qemu-based backends, for example:
export LIBGUESTFS_BACKEND=direct
export LIBGUESTFS_BACKEND_SETTINGS=force_tcg
guestfs_part_get_name
Get the label or name of a partition (for GPT disk images).
Build changes
The following extra packages are required to build libguestfs 1.26:
supermin ≥ 5
Supermin version 5 is required to build this version of libguestfs.
flex, bison
Virt-builder now uses a real parser to parse its metadata file, so
these tools are required.
xz
This is now a required build dependency, where previously it was (in
theory) optional.
Internals
PO message extraction rewritten to be more robust. (Pino Toscano)
podwrapper gives an error if the --insert or --verbatim argument
pattern is not found.
Libguestfs now passes the qemu -enable-fips option to enable FIPS, if
qemu supports it.
./configure --without-qemu can be used if you don't want to specify a
default hypervisor.
Copy-on-write [COW] overlays, used for example for read-only drives,
are now created through an internal backend API (.create_cow_overlay).
Libvirt backend uses some funky C macros to generate XML. These are
simpler and safer.
The ChangeLog file format has changed. It is now just the same as git
log, instead of using a custom format.
Appliance start-up has changed:
* The libguestfs appliance now initializes LVM the same way as it is
done on physical machines.
* The libguestfs appliance does not write an empty string to
/proc/sys/kernel/hotplug when starting up.
Note that you must configure your kernel to have
CONFIG_UEVENT_HELPER_PATH="" otherwise you will get strange LVM
errors (this applies as much to any Linux machine, not just
libguestfs). (Peter Rajnoha)
Libguestfs can now be built on arches that have ocamlc(1) but not
ocamlopt(1). (Hilko Bengen, Olaf Hering)
You cannot use ./configure --disable-daemon --enable-appliance. It made
no sense anyway. Now it is expressly forbidden by the configure script.
The packagelist file uses m4 for macro expansion instead of cpp.
Bugs fixed
https://bugzilla.redhat.com/1073906
java bindings inspect_list_applications2 throws
java.lang.ArrayIndexOutOfBoundsException:
https://bugzilla.redhat.com/1063374
[RFE] enable subscription manager clean or unregister operation to
sysprep
https://bugzilla.redhat.com/1060404
virt-resize does not preserve GPT partition names
https://bugzilla.redhat.com/1057504
mount-local should give a clearer error if root is not mounted
https://bugzilla.redhat.com/1056290
virt-sparsify overwrites block devices if used as output files
https://bugzilla.redhat.com/1055452
libguestfs: error: invalid backend: appliance
https://bugzilla.redhat.com/1054761
guestfs_pvs prints "unknown device" if a physical volume is missing
https://bugzilla.redhat.com/1053847
Recommended default clock/timer settings
https://bugzilla.redhat.com/1046509
ruby-libguestfs throws "expecting 0 or 1 arguments" on
Guestfs::Guestfs.new
https://bugzilla.redhat.com/1045450
Cannot inspect cirros 0.3.1 disk image fully
https://bugzilla.redhat.com/1045033
LIBVIRT_DEFAULT_URI=qemu:///system breaks libguestfs
https://bugzilla.redhat.com/1044585
virt-builder network (eg. --install) doesn't work if resolv.conf sets
nameserver 127.0.0.1
https://bugzilla.redhat.com/1044014
When SSSD is installed, libvirt configuration requires
authentication, but not clear to user
https://bugzilla.redhat.com/1039995
virt-make-fs fails making fat/vfat whole disk: Device partition
expected, not making filesystem on entire device '/dev/sda' (use -I
to override)
https://bugzilla.redhat.com/1039540
virt-sysprep to delete more logfiles
https://bugzilla.redhat.com/1033207
RFE: libguestfs inspection does not recognize Free4NAS live CD
https://bugzilla.redhat.com/1028660
RFE: virt-sysprep/virt-builder should have an option to lock a user
account
https://bugzilla.redhat.com/1026688
libguestfs fails examining libvirt guest with ceph drives: rbd: image
name must begin with a '/'
https://bugzilla.redhat.com/1022431
virt-builder fails if $HOME/.cache doesn't exist
https://bugzilla.redhat.com/1022184
libguestfs: do not use versioned jar file
https://bugzilla.redhat.com/1020806
All libguestfs LVM operations fail on Debian/Ubuntu
https://bugzilla.redhat.com/1008417
Need update helpout of part-set-gpt-type
https://bugzilla.redhat.com/953907
virt-sysprep does not correctly set the hostname on Debian/Ubuntu
https://bugzilla.redhat.com/923355
guestfish prints literal "\n" in error messages
https://bugzilla.redhat.com/660687
guestmount: "touch" command fails: touch: setting times of
`timestamp': Invalid argument
https://bugzilla.redhat.com/593511
[RFE] function to get partition name
https://bugzilla.redhat.com/563450
list-devices returns devices of different types out of order
---
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
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
9 years, 11 months
[libvirt] [PATCH] define NTF_{SELF,MASTER} if undefined
by Guido Günther
Older kernel headers lack this definition (e.g. Debian Wheezy's 3.2)
---
src/util/virnetdevbridge.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 73ec40b..d92a9de 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -919,6 +919,15 @@ virNetDevBridgeSetVlanFiltering(const char *brname ATTRIBUTE_UNUSED,
#if defined(__linux__) && defined(HAVE_LIBNL)
+
+#ifndef NTF_SELF
+#define NTF_SELF 0x02
+#endif
+
+#ifndef NTF_MASTER
+#define NTF_MASTER 0x04
+#endif
+
/* virNetDevBridgeFDBAddDel:
* @mac: the MAC address being added to the table
* @ifname: name of the port (interface) of the bridge that wants this MAC
--
2.1.3
9 years, 11 months