Re: [libvirt] [PATCH] build: fix build --without-remote
On 28.09.2013 04:55, Eric Blake wrote: I tried to test ./configure --without-lxc --without-remote. First, the build failed with some odd errors, such as an inability to build xen, or link failures for virNetTLSInit. But when you think about it, once there is no remote code, all of libvirtd is useless, any stateful driver that depends on libvirtd is also not worth compiling, and any libraries used only by RPC code are not needed. So I patched configure.ac to make for some saner defaults when an explicit disable is attempted. Similarly, since we have migrated virnetdevbridge into generic code, the workaround for Linux kernel stupidity must not depend on stateful drivers being in use. Then there's 'make check' that needs segragation. Wow - quite a bit of cleanup to make --without-remote useful :) * configure.ac: Let --without-remote toggle defaults on stateful drivers and other libraries. Pick up Linux kernel workarounds even when qemu and lxc are not being compiled. * tests/Makefile.am (test_programs): Factor out programs that require remote. * src/libvirt_private.syms (rpc/virnet*.h): Move... * src/libvirt_remote.syms: ...into new file. * src/Makefile.am (SYM_FILES): Ship new syms file. Signed-off-by: Eric Blake ebl...@redhat.com --- Looks big, but most of it is motion of text from splitting a file. It fixes a build failure, but --enable-remote is not a regression for this particular release (it's been broken for a while), so I'll wait for a review even if it misses 1.1.3. configure.ac | 16 +++- src/Makefile.am | 6 ++ src/libvirt_private.syms | 199 src/libvirt_remote.syms | 210 +++ tests/Makefile.am| 19 +++-- 5 files changed, 243 insertions(+), 207 deletions(-) create mode 100644 src/libvirt_remote.syms ACK Although I get this error when running 'make check'. Not a show stopper - this patch fixes the build (I'm able to build --without-remote now), but would be nice if you can get rid of it too. Making check in src make[1]: Entering directory `/home/zippy/work/libvirt/libvirt.git/src' make check-am make[2]: Entering directory `/home/zippy/work/libvirt/libvirt.git/src' make check-local make[3]: Entering directory `/home/zippy/work/libvirt/libvirt.git/src' GEN check-symfile GEN check-symsorting GEN check-drivername GEN check-driverimpls Can't open ./remote/remote_protocol.c: No such file or directory at ./check-driverimpls.pl line 29, line 140903. Can't open ./remote/remote_protocol.h: No such file or directory at ./check-driverimpls.pl line 29, line 140903. Can't open ./remote/lxc_protocol.c: No such file or directory at ./check-driverimpls.pl line 29, line 147465. Can't open ./remote/lxc_protocol.h: No such file or directory at ./check-driverimpls.pl line 29, line 147465. Can't open ./remote/lxc_client_bodies.h: No such file or directory at ./check-driverimpls.pl line 29, line 147465. Can't open ./remote/qemu_protocol.c: No such file or directory at ./check-driverimpls.pl line 29, line 147465. Can't open ./remote/qemu_protocol.h: No such file or directory at ./check-driverimpls.pl line 29, line 147465. Can't open ./remote/qemu_client_bodies.h: No such file or directory at ./check-driverimpls.pl line 29, line 147465. GEN check-aclrules GEN check-aclperms GEN check-augeas-lockd GEN check-augeas-virtlockd make[3]: Leaving directory `/home/zippy/work/libvirt/libvirt.git/src' make[2]: Leaving directory `/home/zippy/work/libvirt/libvirt.git/src' make[1]: Leaving directory `/home/zippy/work/libvirt/libvirt.git/src' Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virfile: safezero: fall back to writing block by block if mmap fails
On 02.10.2013 09:31, Oskari Saarenmaa wrote: mmap can fail on 32-bit systems if we're trying to zero out a lot of data. Fall back to using block-by-block writing in that case. While we could map smaller blocks it's unlikely that this code is used a lot and its easier to just fall back to one of the existing methods. Also modified the block-by-block zeroing to not allocate a megabyte of zeroes if we're writing less than that. Signed-off-by: Oskari Saarenmaa o...@ohmu.fi --- src/util/virfile.c | 34 ++ 1 file changed, 14 insertions(+), 20 deletions(-) ACKed and pushed. Thanks for your contribution! Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: Use maximum guest memory size when getting NUMA placement advice
When starting the VM the guest balloon driver is not loaded at that time. We need to ask numad for placement of the complete VM. --- src/qemu/qemu_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7a30a5e..079f062 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3684,7 +3684,7 @@ int qemuProcessStart(virConnectPtr conn, (vm-def-numatune.memory.placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) { nodeset = virNumaGetAutoPlacementAdvice(vm-def-vcpus, -vm-def-mem.cur_balloon); +vm-def-mem.max_balloon); if (!nodeset) goto cleanup; -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/5] Avoid reporting an error if veth device is already deleted
On 10/02/2013 07:31 PM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com The kernel automatically destroys veth devices when cleaning up the container network namepace. During normal shutdown, it is thus likely that the attempt to run 'ip link del vethN' will fail. If it fails, check if the device exists, and avoid reporting an error if it has gone. This switches to use the virCommand APIs instead of virRun too. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/util/virnetdevveth.c | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 039767f..c0d32c4 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -161,9 +161,20 @@ cleanup: */ int virNetDevVethDelete(const char *veth) { -const char *argv[] = {ip, link, del, veth, NULL}; +virCommandPtr cmd = virCommandNewArgList(ip, link, del, veth, NULL); +int status; -VIR_DEBUG(veth: %s, veth); +if (virCommandRun(cmd, status) 0) +return -1; -return virRun(argv, NULL); +if (status != 0) { +if (!virNetDevExists(veth)) { +VIR_DEBUG(Device %s already deleted (by kernel namespace cleanup), veth); +return 0; +} +virReportError(VIR_ERR_INTERNAL_ERROR, + _(Failed to delete veth device %s), veth); +return -1; +} miss the virCommandFree. +return 0; } -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] LXC: Detect fs support. Mount only supported filesystems
On 10/02/2013 10:05 PM, Bogdan Purcareata wrote: Kept ((access(dstpath, R_OK) 0) || (!lxcCheckFSSupport(mnt-type))) when determining support for the mount. Even if the filesystem type is supported, there is still a chance to fail when building the dstpath (virFileMakePath). If that call fails, starting the container will fail. Specifically encountered this problem for securityfs, as I was unable to mkdir /sys/kernel/security. Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com --- src/lxc/lxc_container.c | 67 + 1 file changed, 67 insertions(+) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 989e920..496443d 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -509,6 +509,67 @@ static int lxcContainerChildMountSort(const void *a, const void *b) # define MS_SLAVE(119) #endif +/* + * This function attempts to detect kernel support + * for a specific filesystem type. This is done by + * inspecting /proc/filesystems. + */ +static int lxcCheckFSSupport(const char *fs_type) +{ +FILE *fp = NULL; +int ret = -1; +const char *fslist = /proc/filesystems; +char *line = NULL; +char *type; +size_t n; + +/* there should be no problem mounting an entry + * with NULL fs type, hence NULL fs types are + * supported */ +if (!fs_type) { + ret = 1; + goto out; +} + +VIR_DEBUG(Checking kernel support for %s in %s, fs_type, fslist); + +if (!(fp = fopen(fslist, r))) { I don't know if we can open /proc/filesystems successfully here if container shares root directory with host, since the /proc filesystem has been unmounted in lxcContainerUnmountForSharedRoot. +virReportSystemError(errno, + _(Unable to read %s), + fslist); +goto out; +} + +while(getline(line, n, fp) 0) { + type = strstr(line, fs_type); + + if (!type) + continue; + + if (!strncmp(type, fs_type, strlen(type))) { The strncmp() function compares the only first (at most) n bytes of s1 and s2. please use STREQ here. + ret = 1; + goto cleanup; + } +} + +if (ferror(fp)) { + virReportSystemError(errno, + _(Error reading line from %s), + fslist); +goto cleanup; +} + +VIR_DEBUG(No kernel support for %s, fs_type); + +ret = 0; + You set ret to 0 here, so the return value 0 means this filesystem is unsupported by kernel, right? what the meaning of return value -1? you return -1 when ferror(fp) is true. +cleanup: +VIR_FREE(line); +VIR_FORCE_FCLOSE(fp); +out: +return ret; +} + static int lxcContainerGetSubtree(const char *prefix, char ***mountsret, size_t *nmountsret) @@ -789,17 +850,23 @@ static int lxcContainerMountBasicFS(bool userns_enabled) for (i = 0; i ARRAY_CARDINALITY(lxcBasicMounts); i++) { virLXCBasicMountInfo const *mnt = lxcBasicMounts[i]; const char *srcpath = NULL; + const char *dstpath = NULL; VIR_DEBUG(Processing %s - %s, mnt-src, mnt-dst); srcpath = mnt-src; + dstpath = mnt-dst; /* Skip if mount doesn't exist in source */ if ((srcpath[0] == '/') (access(srcpath, R_OK) 0)) continue; + if ((access(dstpath, R_OK) 0) || /* mount is not present on host */ + (!lxcCheckFSSupport(mnt-type))) /* no fs support in kernel */ + continue; + The access is in the incorrect place, it should be called after we create mnt-dst. so Move this check after virFileMakePath(mnt-dst). #if WITH_SELINUX if (STREQ(mnt-src, SELINUX_MOUNT) (!is_selinux_enabled() || userns_enabled)) Thanks -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 7/8] test: snapshot: Add REDEFINE support
On 09/25/2013 03:15 PM, Cole Robinson wrote: --- src/test/test_driver.c | 67 -- 1 file changed, 43 insertions(+), 24 deletions(-) Coverity complains here (there's another 6680 6681if (redefine) { (1) Event missing_parentheses: !virDomainSnapshotRedefinePrep(domain, vm, def, snap, update_current, flags) 0 is always false regardless of the values of its operands. Did you intend to either negate the entire comparison expression, in which case parentheses would be required around the entire comparison expression to force that interpretation, or negate the sense of the comparison (that is, use '=' rather than '')? This occurs as the logical operand of if. 6682if (!virDomainSnapshotRedefinePrep(domain, vm, def, snap, 6683 update_current, flags) 0) I believe that !virDomain... is the issue :-) This also generated another Coverity issue regarding DEAD_ERROR_LINE for the 'goto cleanup' that wouldn't be reached. John +if (redefine) { +if (!virDomainSnapshotRedefinePrep(domain, vm, def, snap, + update_current, flags) 0) +goto cleanup; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] free cmd in virNetDevVethCreate
Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/util/virnetdevveth.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 1085217..2d727f1 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -110,6 +110,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) char *veth1auto = NULL; char *veth2auto = NULL; int vethNum = 0; +virCommandPtr cmd = NULL; size_t i; /* @@ -139,7 +140,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) vethNum = veth2num + 1; } -virCommandPtr cmd = virCommandNew(ip); +cmd = virCommandNew(ip); virCommandAddArgList(cmd, link, add, *veth1 ? *veth1 : veth1auto, type, veth, peer, name, @@ -169,6 +170,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) status); VIR_FREE(veth1auto); VIR_FREE(veth2auto); +virCommandFree(cmd); } virReportError(VIR_ERR_INTERNAL_ERROR, @@ -176,6 +178,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) MAX_VETH_RETRIES); cleanup: +virCommandFree(cmd); VIR_FREE(veth1auto); VIR_FREE(veth2auto); return ret; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] free cmd in virNetDevVethDelete
Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/util/virnetdevveth.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 403961b..1085217 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -196,6 +196,7 @@ int virNetDevVethDelete(const char *veth) { virCommandPtr cmd = virCommandNewArgList(ip, link, del, veth, NULL); int status; +int ret = -1; if (virCommandRun(cmd, status) 0) return -1; @@ -203,11 +204,16 @@ int virNetDevVethDelete(const char *veth) if (status != 0) { if (!virNetDevExists(veth)) { VIR_DEBUG(Device %s already deleted (by kernel namespace cleanup), veth); -return 0; +ret = 0; +goto cleanup; } virReportError(VIR_ERR_INTERNAL_ERROR, _(Failed to delete veth device %s), veth); -return -1; +goto cleanup; } -return 0; + +ret = 0; +cleanup: +virCommandFree(cmd); +return ret; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] free cmd in virNetDevVethDelete
On Fri, Oct 04, 2013 at 06:53:52PM +0800, Gao feng wrote: Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/util/virnetdevveth.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 403961b..1085217 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -196,6 +196,7 @@ int virNetDevVethDelete(const char *veth) { virCommandPtr cmd = virCommandNewArgList(ip, link, del, veth, NULL); int status; +int ret = -1; if (virCommandRun(cmd, status) 0) return -1; This needs to jump to cleanup too. @@ -203,11 +204,16 @@ int virNetDevVethDelete(const char *veth) if (status != 0) { if (!virNetDevExists(veth)) { VIR_DEBUG(Device %s already deleted (by kernel namespace cleanup), veth); -return 0; +ret = 0; +goto cleanup; } virReportError(VIR_ERR_INTERNAL_ERROR, _(Failed to delete veth device %s), veth); -return -1; +goto cleanup; } -return 0; + +ret = 0; +cleanup: +virCommandFree(cmd); +return ret; } ACK, I'll push with the fix mentioned above Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] free cmd in virNetDevVethCreate
On Fri, Oct 04, 2013 at 06:53:53PM +0800, Gao feng wrote: Signed-off-by: Gao feng gaof...@cn.fujitsu.com --- src/util/virnetdevveth.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 1085217..2d727f1 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -110,6 +110,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) char *veth1auto = NULL; char *veth2auto = NULL; int vethNum = 0; +virCommandPtr cmd = NULL; size_t i; /* @@ -139,7 +140,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) vethNum = veth2num + 1; } -virCommandPtr cmd = virCommandNew(ip); +cmd = virCommandNew(ip); virCommandAddArgList(cmd, link, add, *veth1 ? *veth1 : veth1auto, type, veth, peer, name, @@ -169,6 +170,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) status); VIR_FREE(veth1auto); VIR_FREE(veth2auto); +virCommandFree(cmd); } This needs to set cmd = NULL, to avoid double-free if the loop terminates. virReportError(VIR_ERR_INTERNAL_ERROR, @@ -176,6 +178,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) MAX_VETH_RETRIES); cleanup: +virCommandFree(cmd); VIR_FREE(veth1auto); VIR_FREE(veth2auto); return ret; ACK, I'll push with the mentioned fix. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 4/8] test: Implement snapshot create/delete/revert APIs
On 09/25/2013 03:15 PM, Cole Robinson wrote: Again stolen from qemu_driver.c, but dropping all the unneeded bits. This aims to copy all the current qemu validation checks since that's the most commonly used real driver, but some of the checks are completely artificial in the test driver. This only supports creation of internal snapshots for initial simplicity. --- v3: Use STRNEQ_NULLABLE for domain_conf.c change src/conf/domain_conf.c | 2 +- src/test/test_driver.c | 504 - 2 files changed, 504 insertions(+), 2 deletions(-) ... A RESOURCE_LEAK Coverity issue - it takes a bit to set up though... +static int +testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, + unsigned int flags) +{ +testConnPtr privconn = snapshot-domain-conn-privateData; +virDomainObjPtr vm = NULL; +virDomainSnapshotObjPtr snap = NULL; +virDomainEventPtr event = NULL; +virDomainEventPtr event2 = NULL; +virDomainDefPtr config = NULL; +int ret = -1; + +virCheckFlags(VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | + VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED | + VIR_DOMAIN_SNAPSHOT_REVERT_FORCE, -1); + +/* We have the following transitions, which create the following events: + * 1. inactive - inactive: none + * 2. inactive - running: EVENT_STARTED + * 3. inactive - paused: EVENT_STARTED, EVENT_PAUSED + * 4. running - inactive: EVENT_STOPPED + * 5. running - running: none + * 6. running - paused: EVENT_PAUSED + * 7. paused - inactive: EVENT_STOPPED + * 8. paused - running: EVENT_RESUMED + * 9. paused - paused: none + * Also, several transitions occur even if we fail partway through, + * and use of FORCE can cause multiple transitions. + */ + +if (!(vm = testDomObjFromSnapshot(snapshot))) +return -1; + +if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) +goto cleanup; + +testDriverLock(privconn); + +if (!vm-persistent +snap-def-state != VIR_DOMAIN_RUNNING +snap-def-state != VIR_DOMAIN_PAUSED +(flags (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | + VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) == 0) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(transient domain needs to request run or pause + to revert to inactive snapshot)); +goto cleanup; +} + +if (!(flags VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { +if (!snap-def-dom) { +virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, + _(snapshot '%s' lacks domain '%s' rollback info), + snap-def-name, vm-def-name); +goto cleanup; +} +if (virDomainObjIsActive(vm) +!(snap-def-state == VIR_DOMAIN_RUNNING + || snap-def-state == VIR_DOMAIN_PAUSED) +(flags (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | + VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED))) { +virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, %s, + _(must respawn guest to start inactive snapshot)); +goto cleanup; +} +} + + +if (vm-current_snapshot) { +vm-current_snapshot-def-current = false; +vm-current_snapshot = NULL; +} + +snap-def-current = true; +config = virDomainDefCopy(snap-def-dom, + privconn-caps, privconn-xmlopt, true); +if (!config) +goto cleanup; + 6953goto cleanup; 6954 (20) Event cond_false: Condition snap-def-state == VIR_DOMAIN_RUNNING, taking false branch (21) Event cond_false: Condition snap-def-state == VIR_DOMAIN_PAUSED, taking false branch 6955if (snap-def-state == VIR_DOMAIN_RUNNING || 6956snap-def-state == VIR_DOMAIN_PAUSED) { +if (snap-def-state == VIR_DOMAIN_RUNNING || +snap-def-state == VIR_DOMAIN_PAUSED) { +/* Transitions 2, 3, 5, 6, 8, 9 */ +bool was_running = false; +bool was_stopped = false; + +if (virDomainObjIsActive(vm)) { +/* Transitions 5, 6, 8, 9 */ +/* Check for ABI compatibility. */ +if (!virDomainDefCheckABIStability(vm-def, config)) { +virErrorPtr err = virGetLastError(); + +if (!(flags VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { +/* Re-spawn error using correct category. */ +if (err-code == VIR_ERR_CONFIG_UNSUPPORTED) +virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, %s, + err-str2); +goto cleanup; +} + +virResetError(err); +testDomainShutdownState(snapshot-domain, vm, +
Re: [libvirt] [PATCH 0/2] btrfs subvolume management
On Tue, Sep 10, 2013 at 09:56:48PM +0300, Oskari Saarenmaa wrote: Date: Tue, 10 Sep 2013 21:56:48 +0300 From: Oskari Saarenmaa o...@ohmu.fi To: libvir-list@redhat.com Subject: [libvirt] [PATCH 0/2] btrfs subvolume management Moved btrfs subvolume management to storage_backend_fs.c instead of implementing it as a separate pool as suggested by Daniel P. Berrange in https://www.redhat.com/archives/libvir-list/2013-September/msg00316.html Ping, anyone had a chance to review this yet? Thanks, Oskari -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] LXC: Detect fs support. Mount only supported filesystems
-Original Message- From: Gao feng [mailto:gaof...@cn.fujitsu.com] Sent: Friday, October 04, 2013 12:55 PM To: Purcareata Bogdan-B43198 Cc: libvir-list@redhat.com Subject: Re: [libvirt] [PATCH v2] LXC: Detect fs support. Mount only supported filesystems On 10/02/2013 10:05 PM, Bogdan Purcareata wrote: Kept ((access(dstpath, R_OK) 0) || (!lxcCheckFSSupport(mnt-type))) when determining support for the mount. Even if the filesystem type is supported, there is still a chance to fail when building the dstpath (virFileMakePath). If that call fails, starting the container will fail. Specifically encountered this problem for securityfs, as I was unable to mkdir /sys/kernel/security. Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com --- src/lxc/lxc_container.c | 67 + 1 file changed, 67 insertions(+) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 989e920..496443d 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -509,6 +509,67 @@ static int lxcContainerChildMountSort(const void *a, const void *b) # define MS_SLAVE(119) #endif +/* + * This function attempts to detect kernel support + * for a specific filesystem type. This is done by + * inspecting /proc/filesystems. + */ +static int lxcCheckFSSupport(const char *fs_type) +{ +FILE *fp = NULL; +int ret = -1; +const char *fslist = /proc/filesystems; +char *line = NULL; +char *type; +size_t n; + +/* there should be no problem mounting an entry + * with NULL fs type, hence NULL fs types are + * supported */ +if (!fs_type) { + ret = 1; + goto out; +} + +VIR_DEBUG(Checking kernel support for %s in %s, fs_type, fslist); + +if (!(fp = fopen(fslist, r))) { I don't know if we can open /proc/filesystems successfully here if container shares root directory with host, since the /proc filesystem has been unmounted in lxcContainerUnmountForSharedRoot. Right. I just noticed the search for proc fails, since /proc/filesystem requires procfs to be mounted. (Un)fortunately, my handling of lxcCheckFSSupport() bypassed this error, and mounted procfs anyways. I will update the code with a proper handle for the error code. I just don't see how I can handle all filesystem entries in an uniform manner, since each one is so special. +virReportSystemError(errno, + _(Unable to read %s), + fslist); +goto out; +} + +while(getline(line, n, fp) 0) { + type = strstr(line, fs_type); + + if (!type) + continue; + + if (!strncmp(type, fs_type, strlen(type))) { The strncmp() function compares the only first (at most) n bytes of s1 and s2. please use STREQ here. Thanks, I will update. + ret = 1; + goto cleanup; + } +} + +if (ferror(fp)) { + virReportSystemError(errno, + _(Error reading line from %s), + fslist); +goto cleanup; +} + +VIR_DEBUG(No kernel support for %s, fs_type); + +ret = 0; + You set ret to 0 here, so the return value 0 means this filesystem is unsupported by kernel, right? what the meaning of return value -1? you return -1 when ferror(fp) is true. So I thought it would be like this: - -1 - error encountered - 0 - no error, no kernel support for the filesystem - 1 - no error, kernel support present +cleanup: +VIR_FREE(line); +VIR_FORCE_FCLOSE(fp); +out: +return ret; +} + static int lxcContainerGetSubtree(const char *prefix, char ***mountsret, size_t *nmountsret) @@ -789,17 +850,23 @@ static int lxcContainerMountBasicFS(bool userns_enabled) for (i = 0; i ARRAY_CARDINALITY(lxcBasicMounts); i++) { virLXCBasicMountInfo const *mnt = lxcBasicMounts[i]; const char *srcpath = NULL; + const char *dstpath = NULL; VIR_DEBUG(Processing %s - %s, mnt-src, mnt-dst); srcpath = mnt-src; + dstpath = mnt-dst; /* Skip if mount doesn't exist in source */ if ((srcpath[0] == '/') (access(srcpath, R_OK) 0)) continue; + if ((access(dstpath, R_OK) 0) || /* mount is not present on host */ + (!lxcCheckFSSupport(mnt-type))) /* no fs support in kernel */ + continue; + The access is in the incorrect place, it should be called after we create mnt- dst. so Move this check after virFileMakePath(mnt-dst). My specific problem was that mounting security failed even before reaching the actual mount syscall. It failed when doing virFileMakePath(/sys/kernel/securityfs),
Re: [libvirt] [PATCH] qemu: Use maximum guest memory size when getting NUMA placement advice
On 10/04/2013 03:51 AM, Peter Krempa wrote: When starting the VM the guest balloon driver is not loaded at that time. We need to ask numad for placement of the complete VM. --- src/qemu/qemu_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ACK. diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7a30a5e..079f062 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3684,7 +3684,7 @@ int qemuProcessStart(virConnectPtr conn, (vm-def-numatune.memory.placement_mode == VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) { nodeset = virNumaGetAutoPlacementAdvice(vm-def-vcpus, -vm-def-mem.cur_balloon); +vm-def-mem.max_balloon); if (!nodeset) goto cleanup; -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nodedev: Resolve Relax-NG validity error
On 10/03/2013 07:18 PM, Eric Blake wrote: On 10/03/2013 03:16 PM, John Ferlan wrote: Commit id 'c4a4603de' added an output path to the nodedev xml, but did not update the schema. This resulted in the failure of the 'virt-xml-validate' on a file generated by 'virsh nodedev-dumpxml pci__00_00_0' (for example). This was found/seen by running autotest on my host. --- I'm not sure if something like this needs to be backported or not, but I'm sure someone will let me know... docs/schemas/nodedev.rng | 3 +++ 1 file changed, 3 insertions(+) ACK. At the moment, I wouldn't worry about backporting it unless someone opens a bugzilla complaining about hitting the failure. Pushed John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 4/8] test: Implement snapshot create/delete/revert APIs
On 10/04/2013 07:05 AM, John Ferlan wrote: On 09/25/2013 03:15 PM, Cole Robinson wrote: Again stolen from qemu_driver.c, but dropping all the unneeded bits. This aims to copy all the current qemu validation checks since that's the most commonly used real driver, but some of the checks are completely artificial in the test driver. This only supports creation of internal snapshots for initial simplicity. --- v3: Use STRNEQ_NULLABLE for domain_conf.c change src/conf/domain_conf.c | 2 +- src/test/test_driver.c | 504 - 2 files changed, 504 insertions(+), 2 deletions(-) ... A RESOURCE_LEAK Coverity issue - it takes a bit to set up though... +static int +testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, + unsigned int flags) +{ +testConnPtr privconn = snapshot-domain-conn-privateData; +virDomainObjPtr vm = NULL; +virDomainSnapshotObjPtr snap = NULL; +virDomainEventPtr event = NULL; +virDomainEventPtr event2 = NULL; +virDomainDefPtr config = NULL; +int ret = -1; + +virCheckFlags(VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | + VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED | + VIR_DOMAIN_SNAPSHOT_REVERT_FORCE, -1); + +/* We have the following transitions, which create the following events: + * 1. inactive - inactive: none + * 2. inactive - running: EVENT_STARTED + * 3. inactive - paused: EVENT_STARTED, EVENT_PAUSED + * 4. running - inactive: EVENT_STOPPED + * 5. running - running: none + * 6. running - paused: EVENT_PAUSED + * 7. paused - inactive: EVENT_STOPPED + * 8. paused - running: EVENT_RESUMED + * 9. paused - paused: none + * Also, several transitions occur even if we fail partway through, + * and use of FORCE can cause multiple transitions. + */ + +if (!(vm = testDomObjFromSnapshot(snapshot))) +return -1; + +if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) +goto cleanup; + +testDriverLock(privconn); + +if (!vm-persistent +snap-def-state != VIR_DOMAIN_RUNNING +snap-def-state != VIR_DOMAIN_PAUSED +(flags (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | + VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) == 0) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(transient domain needs to request run or pause + to revert to inactive snapshot)); +goto cleanup; +} + +if (!(flags VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { +if (!snap-def-dom) { +virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, + _(snapshot '%s' lacks domain '%s' rollback info), + snap-def-name, vm-def-name); +goto cleanup; +} +if (virDomainObjIsActive(vm) +!(snap-def-state == VIR_DOMAIN_RUNNING + || snap-def-state == VIR_DOMAIN_PAUSED) +(flags (VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING | + VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED))) { +virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, %s, + _(must respawn guest to start inactive snapshot)); +goto cleanup; +} +} + + +if (vm-current_snapshot) { +vm-current_snapshot-def-current = false; +vm-current_snapshot = NULL; +} + +snap-def-current = true; +config = virDomainDefCopy(snap-def-dom, + privconn-caps, privconn-xmlopt, true); +if (!config) +goto cleanup; + 6953 goto cleanup; 6954 (20) Event cond_false:Condition snap-def-state == VIR_DOMAIN_RUNNING, taking false branch (21) Event cond_false:Condition snap-def-state == VIR_DOMAIN_PAUSED, taking false branch 6955 if (snap-def-state == VIR_DOMAIN_RUNNING || 6956 snap-def-state == VIR_DOMAIN_PAUSED) { +if (snap-def-state == VIR_DOMAIN_RUNNING || +snap-def-state == VIR_DOMAIN_PAUSED) { +/* Transitions 2, 3, 5, 6, 8, 9 */ +bool was_running = false; +bool was_stopped = false; + +if (virDomainObjIsActive(vm)) { +/* Transitions 5, 6, 8, 9 */ +/* Check for ABI compatibility. */ +if (!virDomainDefCheckABIStability(vm-def, config)) { +virErrorPtr err = virGetLastError(); + +if (!(flags VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { +/* Re-spawn error using correct category. */ +if (err-code == VIR_ERR_CONFIG_UNSUPPORTED) +virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, %s, + err-str2); +goto cleanup; +} + +virResetError(err); +
[libvirt] [PATCHv3 0/3] Change preference of default PCI passthrough type to VFIO
Version 3 incorporates fixes for issues I found while testing this series a bit better than the previous one. The main objective of this series is to add checks if VFIO is enabled on a host and if it's the case use it as a default PCI passthrough type instead of the legacy KVM passthrough type. Peter Krempa (3): qemu: hostdev: Refactor PCI passhrough handling qemu: hostdev: Add checks if PCI passthrough is availabe in the host qemu: Prefer VFIO for PCI device passthrough docs/formatdomain.html.in | 9 ++- src/conf/domain_conf.h| 2 +- src/qemu/qemu_command.c | 28 ++--- src/qemu/qemu_hostdev.c | 143 ++ src/qemu/qemu_hostdev.h | 5 ++ src/qemu/qemu_hotplug.c | 29 ++ src/qemu/qemu_process.c | 18 -- tests/qemuxml2argvtest.c | 11 8 files changed, 214 insertions(+), 31 deletions(-) -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv3 3/3] qemu: Prefer VFIO for PCI device passthrough
Prefer using VFIO (if available) to the legacy KVM device passthrough. With this patch a PCI passthrough device without the driver configured will be started with VFIO if it's available on the host. If not legacy KVM passthrough is checked and error is reported if it's not available. --- docs/formatdomain.html.in | 9 - src/conf/domain_conf.h| 2 +- src/qemu/qemu_command.c | 3 ++- src/qemu/qemu_hostdev.c | 21 +++-- src/qemu/qemu_hostdev.h | 3 ++- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_process.c | 15 --- tests/qemuxml2argvtest.c | 11 +++ 8 files changed, 48 insertions(+), 18 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3689399..6f3f7cf 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2755,11 +2755,10 @@ backend, which is compatible with UEFI SecureBoot) or kvm (for the legacy device assignment handled directly by the KVM kernel module)span class=sinceSince 1.0.5 (QEMU and KVM -only, requires kernel 3.6 or newer)/span. Currently, kvm -is the default used by libvirt when not explicitly provided, -but since the two are functionally equivalent, this default -could be changed in the future with no impact to domains that -don't specify anything. +only, requires kernel 3.6 or newer)/span. The default, when +the driver name is not explicitly specified, is to check wether +VFIO is available and use it if it's the case. If VFIO is not +available, the legacy kvm assignment is attempted. /dd dtcodereadonly/code/dt ddIndicates that the device is readonly, only supported by SCSI host diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f20a916..6b825d8 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -399,7 +399,7 @@ enum virDomainHostdevSubsysType { /* the backend driver used for PCI hostdev devices */ typedef enum { -VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* currently kvm, could change */ +VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automaticaly, prefer VFIO */ VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,/* force legacy kvm style */ VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO, /* force vfio */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ecf26cc..a4742fa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5487,7 +5487,6 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def, switch ((virDomainHostdevSubsysPciBackendType) dev-source.subsys.u.pci.backend) { -case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: virBufferAddLit(buf, pci-assign); if (configfd *configfd) @@ -5498,6 +5497,8 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def, virBufferAddLit(buf, vfio-pci); break; + +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(PCI passhthrough type needs to be specified)); diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index dbbc2b4..ad408d8 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -1366,7 +1366,8 @@ qemuHostdevHostSupportsPassthroughLegacy(void) bool qemuHostdevHostVerifySupport(virDomainHostdevDefPtr *hostdevs, - size_t nhostdevs) + size_t nhostdevs, + virQEMUCapsPtr qemuCaps) { int supportsPassthroughKVM = -1; int supportsPassthroughVFIO = -1; @@ -1387,6 +1388,23 @@ qemuHostdevHostVerifySupport(virDomainHostdevDefPtr *hostdevs, } switch ((virDomainHostdevSubsysPciBackendType) *backend) { +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: +if (supportsPassthroughVFIO +virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { +*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; +} else if (supportsPassthroughKVM + (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE) || +virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))) { +*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM; +} else { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(host doesn't support passthrough of + host PCI devices)); +return false; +} + +break; + case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: if (!supportsPassthroughVFIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, @@ -1395,7 +1413,6 @@ qemuHostdevHostVerifySupport(virDomainHostdevDefPtr *hostdevs, }
[libvirt] [PATCH v2] test: Fix coverity warnings
--- v2: Address Eric's suggestion Address additional coverity warnings pointed out by John src/test/test_driver.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 255cc2b..c2e530e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6547,16 +6547,12 @@ testDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, { virDomainObjPtr vm = NULL; int ret = -1; -virDomainSnapshotObjPtr snap = NULL; virCheckFlags(0, -1); if (!(vm = testDomObjFromSnapshot(snapshot))) goto cleanup; -if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) -goto cleanup; - ret = (vm-current_snapshot STREQ(snapshot-name, vm-current_snapshot-def-name)); @@ -6573,14 +6569,13 @@ testDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, { virDomainObjPtr vm = NULL; int ret = -1; -virDomainSnapshotObjPtr snap = NULL; virCheckFlags(0, -1); if (!(vm = testDomObjFromSnapshot(snapshot))) goto cleanup; -if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) +if (!testSnapObjFromSnapshot(vm, snapshot)) goto cleanup; ret = 1; @@ -6679,8 +6674,8 @@ testDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; if (redefine) { -if (!virDomainSnapshotRedefinePrep(domain, vm, def, snap, - update_current, flags) 0) +if (virDomainSnapshotRedefinePrep(domain, vm, def, snap, + update_current, flags) 0) goto cleanup; } else { if (!(def-dom = virDomainDefCopy(vm-def, @@ -7078,6 +7073,8 @@ cleanup: testDomainEventQueue(privconn, event); if (event2) testDomainEventQueue(privconn, event2); +} else { +virDomainEventFree(event2); } virObjectUnlock(vm); testDriverUnlock(privconn); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv3 1/3] qemu: hostdev: Refactor PCI passhrough handling
To simplify future patches dealing with this code, simplify and refactor some conditions to switch statements. --- src/qemu/qemu_command.c | 27 ++- src/qemu/qemu_hotplug.c | 27 --- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e976466..ecf26cc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5485,14 +5485,25 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def, { virBuffer buf = VIR_BUFFER_INITIALIZER; -if (dev-source.subsys.u.pci.backend -== VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { -virBufferAddLit(buf, vfio-pci); -} else { +switch ((virDomainHostdevSubsysPciBackendType) +dev-source.subsys.u.pci.backend) { +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: virBufferAddLit(buf, pci-assign); if (configfd *configfd) virBufferAsprintf(buf, ,configfd=%s, configfd); +break; + +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: +virBufferAddLit(buf, vfio-pci); +break; + +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(PCI passhthrough type needs to be specified)); +break; } + virBufferAsprintf(buf, ,host=%.2x:%.2x.%.1x, dev-source.subsys.u.pci.addr.bus, dev-source.subsys.u.pci.addr.slot, @@ -9232,7 +9243,6 @@ qemuBuildCommandLine(virConnectPtr conn, VIR_FREE(devstr); } - /* Add host passthrough hardware */ for (i = 0; i def-nhostdevs; i++) { virDomainHostdevDefPtr hostdev = def-hostdevs[i]; @@ -9305,9 +9315,9 @@ qemuBuildCommandLine(virConnectPtr conn, /* PCI */ if (hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { +int backend = hostdev-source.subsys.u.pci.backend; -if (hostdev-source.subsys.u.pci.backend -== VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { +if (backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, _(VFIO PCI device assignment is not @@ -9321,8 +9331,7 @@ qemuBuildCommandLine(virConnectPtr conn, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { char *configfd_name = NULL; -if ((hostdev-source.subsys.u.pci.backend - != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) +if ((backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_CONFIGFD)) { int configfd = qemuOpenPCIConfig(hostdev); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 818c726..ae2cbc0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1134,6 +1134,7 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver, int configfd = -1; char *configfd_name = NULL; bool releaseaddr = false; +int *backend = hostdev-source.subsys.u.pci.backend; if (VIR_REALLOC_N(vm-def-hostdevs, vm-def-nhostdevs + 1) 0) return -1; @@ -1142,10 +1143,8 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver, hostdev, 1) 0) return -1; -if (hostdev-source.subsys.u.pci.backend -== VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) { -unsigned long long memKB; - +switch ((virDomainHostdevSubsysPciBackendType) *backend) { +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, _(VFIO PCI device assignment is not @@ -1157,11 +1156,18 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver, * In this case, the guest's memory may already be locked, but it * doesn't hurt to change the limit to the same value. */ -vm-def-hostdevs[vm-def-nhostdevs++] = hostdev; -memKB = vm-def-mem.hard_limit ? -vm-def-mem.hard_limit : vm-def-mem.max_balloon + 1024 * 1024; -virProcessSetMaxMemLock(vm-pid, memKB); -vm-def-hostdevs[vm-def-nhostdevs--] = NULL; +if (vm-def-mem.hard_limit) +virProcessSetMaxMemLock(vm-pid, vm-def-mem.hard_limit); +else +virProcessSetMaxMemLock(vm-pid, +vm-def-mem.max_balloon + (1024 * 1024)); + +break; + +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: +break; } if
[libvirt] [PATCHv3 2/3] qemu: hostdev: Add checks if PCI passthrough is availabe in the host
Add code to check availability of PCI passhthrough using VFIO and the legacy KVM passthrough and use it when starting VMs and hotplugging devices to live machine. --- src/qemu/qemu_hostdev.c | 126 src/qemu/qemu_hostdev.h | 4 ++ src/qemu/qemu_hotplug.c | 4 ++ src/qemu/qemu_process.c | 5 ++ 4 files changed, 139 insertions(+) diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 21fe47f..dbbc2b4 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -23,6 +23,11 @@ #include config.h +#include dirent.h +#include fcntl.h +#include sys/ioctl.h +#include errno.h + #include qemu_hostdev.h #include virlog.h #include virerror.h @@ -31,6 +36,7 @@ #include virusb.h #include virscsi.h #include virnetdev.h +#include virfile.h #define VIR_FROM_THIS VIR_FROM_QEMU @@ -1287,3 +1293,123 @@ void qemuDomainReAttachHostDevices(virQEMUDriverPtr driver, qemuDomainReAttachHostScsiDevices(driver, def-name, def-hostdevs, def-nhostdevs); } + + +static bool +qemuHostdevHostSupportsPassthroughVFIO(void) +{ +DIR *iommuDir = NULL; +struct dirent *iommuGroup = NULL; +bool ret = false; + +/* condition 1 - /sys/kernel/iommu_groups/ contains entries */ +if (!(iommuDir = opendir(/sys/kernel/iommu_groups/))) +goto cleanup; + +while ((iommuGroup = readdir(iommuDir))) { +/* skip ./ ../ */ +if (STRPREFIX(iommuGroup-d_name, .)) +continue; + +/* assume we found a group */ +break; +} + +if (!iommuGroup) +goto cleanup; +/* okay, iommu is on and recognizes groups */ + +/* condition 2 - /dev/vfio/vfio exists */ +if (!virFileExists(/dev/vfio/vfio)) +goto cleanup; + +ret = true; + +cleanup: +if (iommuDir) +closedir(iommuDir); + +return ret; +} + + +#if HAVE_LINUX_KVM_H +# include linux/kvm.h +static bool +qemuHostdevHostSupportsPassthroughLegacy(void) +{ +int kvmfd = -1; +bool ret = false; + +if ((kvmfd = open(/dev/kvm, O_RDONLY)) 0) +goto cleanup; + +# ifdef KVM_CAP_IOMMU +if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) = 0) +goto cleanup; + +ret = true; +# endif + +cleanup: +VIR_FORCE_CLOSE(kvmfd); + +return ret; +} +#else +static bool +qemuHostdevHostSupportsPassthroughLegacy(void) +{ +return false; +} +#endif + +bool +qemuHostdevHostVerifySupport(virDomainHostdevDefPtr *hostdevs, + size_t nhostdevs) +{ +int supportsPassthroughKVM = -1; +int supportsPassthroughVFIO = -1; +size_t i; + +/* assign defaults for hostdev passthrough */ +for (i = 0; i nhostdevs; i++) { +virDomainHostdevDefPtr hostdev = hostdevs[i]; + +if (hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS +hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { +int *backend = hostdev-source.subsys.u.pci.backend; + +/* cache host state of passthrough support */ +if (supportsPassthroughKVM == -1 || supportsPassthroughVFIO == -1) { +supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy(); +supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); +} + +switch ((virDomainHostdevSubsysPciBackendType) *backend) { +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: +if (!supportsPassthroughVFIO) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(host doesn't support VFIO PCI passthrough)); +return false; +} +break; + +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: +if (!supportsPassthroughKVM) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(host doesn't support legacy PCI passthrough)); +return false; +} + +break; + +case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: +break; +} +} +} + +return true; +} diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index 327d4d5..6d88830 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -69,4 +69,8 @@ int qemuDomainHostdevNetConfigReplace(virDomainHostdevDefPtr hostdev, int qemuDomainHostdevNetConfigRestore(virDomainHostdevDefPtr hostdev, char *stateDir); +bool qemuHostdevHostVerifySupport(virDomainHostdevDefPtr *hostdevs, + size_t nhostdevs); + + #endif /* __QEMU_HOSTDEV_H__ */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ae2cbc0..c72fdc3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1143,6 +1143,10 @@ int
Re: [libvirt] [PATCH v2] test: Fix coverity warnings
On 10/04/2013 06:55 AM, Cole Robinson wrote: --- v2: Address Eric's suggestion Address additional coverity warnings pointed out by John src/test/test_driver.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Guide to view the libvirt source.
hi all, i am new to this libvirt. Any guide or reference is available to know more things libvirt (individual programs). because it will give me some idea to get about the libvirt and its corresponding programs. If there is available means please guide and share me. i want to give my contribution to this community. Lot of thanks in advance. Regards, cooldharma06. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Use maximum guest memory size when getting NUMA placement advice
On 10/04/13 13:50, Eric Blake wrote: On 10/04/2013 03:51 AM, Peter Krempa wrote: When starting the VM the guest balloon driver is not loaded at that time. We need to ask numad for placement of the complete VM. --- src/qemu/qemu_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ACK. Pushed; thanks. Peter signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] test: Fix coverity warnings
On 10/04/2013 08:55 AM, Cole Robinson wrote: --- v2: Address Eric's suggestion Address additional coverity warnings pointed out by John src/test/test_driver.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 255cc2b..c2e530e 100644 I can confirm that by applying this all Coverity warnings are gone John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] virfile: safezero: fix buffer allocation max size
My previous commit 7dc1d4ab was supposed to change safezero to allocate 1 megabyte at maximum, but had the logic reversed and will allocate 1 megabyte at minimum (and a lot more at maximum.) Signed-off-by: Oskari Saarenmaa o...@ohmu.fi --- src/util/virfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index f662127..e10de5a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1075,7 +1075,7 @@ safezero(int fd, off_t offset, off_t len) /* Split up the write in small chunks so as not to allocate lots of RAM */ remain = len; -bytes = MAX(1024 * 1024, len); +bytes = MIN(1024 * 1024, len); r = VIR_ALLOC_N(buf, bytes); if (r 0) { -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Guide to view the libvirt source.
On 10/04/2013 07:04 AM, cooldharma06 wrote: hi all, i am new to this libvirt. Any guide or reference is available to know more things libvirt (individual programs). because it will give me some idea to get about the libvirt and its corresponding programs. If there is available means please guide and share me. i want to give my contribution to this community. A good starting point is to read the HACKING document, and to start reviewing patches on the devel list. That will give you a feel for what the coding style is, and how to submit a patch. http://libvirt.org/hacking.html -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] test: Fix coverity warnings
On 10/04/2013 08:59 AM, Eric Blake wrote: On 10/04/2013 06:55 AM, Cole Robinson wrote: --- v2: Address Eric's suggestion Address additional coverity warnings pointed out by John src/test/test_driver.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) ACK. Thanks, pushed now. - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virfile: safezero: fix buffer allocation max size
On 04.10.2013 15:49, Oskari Saarenmaa wrote: My previous commit 7dc1d4ab was supposed to change safezero to allocate 1 megabyte at maximum, but had the logic reversed and will allocate 1 megabyte at minimum (and a lot more at maximum.) Signed-off-by: Oskari Saarenmaa o...@ohmu.fi --- src/util/virfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index f662127..e10de5a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1075,7 +1075,7 @@ safezero(int fd, off_t offset, off_t len) /* Split up the write in small chunks so as not to allocate lots of RAM */ remain = len; -bytes = MAX(1024 * 1024, len); +bytes = MIN(1024 * 1024, len); r = VIR_ALLOC_N(buf, bytes); if (r 0) { Ooops. ACKed and pushed. Meanwhile I'm gonna hide someplace to be alone with shame :) Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] storage: fix file allocation behavior in file cloning
On 30.09.2013 18:57, Oskari Saarenmaa wrote: Fixed the safezero call for allocating the rest of the file after cloning an existing volume; it used to always use a zero offset, causing it to only allocate the beginning of the file. Also modified file creation to try to use fallocate(2) to pre-allocate disk space before copying any data to make sure it fails early on if disk is full and makes sure we can skip zero blocks when copying file contents. If fallocate isn't available we will zero out the rest of the file after cloning and only use sparse cloning if client requested a lower allocation than the input volume's capacity. Signed-off-by: Oskari Saarenmaa o...@ohmu.fi --- the safezero mmap issue fixed in my previous patch never showed up because all safezero calls previously had 0 offset (or maybe everyone's using posix_fallocate) configure.ac | 8 src/storage/storage_backend.c | 35 ++- 2 files changed, 34 insertions(+), 9 deletions(-) ACKed and pushed. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv4 1/4] net-dhcp-leases: Implement the public APIs
The dnsmasq guys have confirmed that the code exposing the environment variable DNSMASQ_MAC in case ipv6 will be out in the coming week as an official release. Meanwhile, I had a chat with mrjester on #ipv6 regarding fields which are supposed to be useful to users in case DHCPv6 is used. I've attached the chat history. Now, coming to the API, I do think that supporting --dhcp-script will be a good option. So that we don't land up with half-implementations. So I am hoping that we are in a position to finalize the virNetworkDHCPLeases struct now. In case of DHCPv6, we should be exposing expirytime, MAC Address, IP Address, hostname, client DUID, IAID and the interface name to which the lease is provided (which can be obtained from the env variable DNSMASQ_INTERFACE) I personally think the easiest way would be to have all possible values in the virNetworkDHCPLeases struct and let the user decide which one he wants. The ones which are not available, will be set to NULL. -- Nehal J Wani nehaljwani Hello! I am developing an API for libvirt which exposes leases API to the users for a particular network. Since we are also planning to include support for DHCPv6, I would like to know which fields in a dhcpv6 lease are important, from a user's point of view. Example, will exposing IAID be useful to a user or not? mrjester Yes. mrjester DUID mrjester DHCP server mrjester Lease time nehaljwani mrjester, I am talking more in terms of info related to guests, not the dhcp server itself mrjester That is relevant to the client. mrjester The DHCP server that issues the lease. mrjester Useful for troubleshooting. nehaljwani and which fields are important in the leases info of the client machines? mrjester Ahh. I see. nehaljwani out of expirytime, mac address, iaid, client duid, ip address nehaljwani etc mrjester IAID, DUID, Addres, mrjester MAC wouldn't hurt, but not really relevant to DHCPv6 nehaljwani Could you explain a bit more on that? I mean, why is MAC irrelevant, but IAID is more relevant? mrjester MAC isn't used in the standard DHCP request. mrjester DUID is derived from the MAC mrjester but is used instead mrjester IAID indicates the interface that the request is for. mrjester There are some variants of DHCP which use the actual MAC, but that is non-standard behavior. Not invalid, just not the default. nehaljwani Well, currently libvirt uses dnsmasq mrjester Probably makes sense to have the MAC as well then since dnsmasq tries to do some magic with DDNS between v4 and v6. mrjester eg. Putting in DDNS entries for a SLAAC address based on the v4 address. mrjester Short version, since you are using dnsmasq, yes exposing the MAC Addr makes sense. nehaljwani the dnsmasq guys don't release the MAC in the lease file. We have to give the --dchp-script option to dnsmasq to extract it from environment variables. mrjester What about on the v4 side? nehaljwani On the v4 side, they do. mrjester or at the itnerface. mrjester Good enough I would think mrjester Shouldn't need to pull it twice. nehaljwani mrjester, http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2013q4/007589.html mrjester IMO, the ideal situation is that all details in the lease file are exportable via the API and you allow the consumers to decide what to request/display. nehaljwani By all, do you mean, the server DUID as well? mrjester Why not? While you nor I may see a use for it today, someone will probably come up with a clever use. mrjester Why not aside from the extra dev work of course. nehaljwani And if we are talking in present day scenario, which fields will be important for a user? mrjester Does the lease expose the DHCP options that were sent? mrjester DNS, SNTP servers mrjester Address, DUID, IAID, Expiriry, DHCP Server IP would probably be the most used today. mrjester If you have the options in the lease file, those too. nehaljwani mrjester, if we are taking about only the leases, then, in case of ipv4, they are : expirytime, mac address, ip address, hostname, client id and in case of ipv6, they are: server duid, expirytime, IAID, ip address, hostname, client DUID mrjester Server DUID is the only one of those that has questionable usefulness. mrjester Since it is not easily associated to a server. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Xen Project Developer Summit: check the schedule and register!
Hi all, The program for the Xen Project Developer Summit 2013 has been announced! Get more details at the links below: xendevelopersummit2013.sched.org/ http://blog.xen.org/index.php/2013/10/02/xen-project-developer-summit-line-up-announced/ http://events.linuxfoundation.org/events/xen-project-developer-summit Don't miss the opportunity to come and see what's going on in the Xen Project's community. Register and join us in Edinburgh! Regards, Dario -- This happens because I choose it to happen! (Raistlin Majere) - Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems RD Ltd., Cambridge (UK) signature.asc Description: This is a digitally signed message part -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] docs: aclpolkit: Fix a heading typo
--- docs/aclpolkit.html.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aclpolkit.html.in b/docs/aclpolkit.html.in index 1a09139..91b5296 100644 --- a/docs/aclpolkit.html.in +++ b/docs/aclpolkit.html.in @@ -303,7 +303,7 @@ /p -h2a name=checksWriting acces control policies/a/h2 +h2a name=checksWriting access control policies/a/h2 p If using versions of polkit prior to 0.106 then it is only -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: aclpolkit: Fix a heading typo
On 10/04/2013 01:39 PM, Cole Robinson wrote: --- docs/aclpolkit.html.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aclpolkit.html.in b/docs/aclpolkit.html.in index 1a09139..91b5296 100644 --- a/docs/aclpolkit.html.in +++ b/docs/aclpolkit.html.in @@ -303,7 +303,7 @@ /p -h2a name=checksWriting acces control policies/a/h2 +h2a name=checksWriting access control policies/a/h2 p If using versions of polkit prior to 0.106 then it is only Meant to say I pushed this as trivial. - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: aclpolkit: Fix a heading typo
On 10/04/2013 11:39 AM, Cole Robinson wrote: --- docs/aclpolkit.html.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ACK. For stuff like this, you can push under the trivial rule. diff --git a/docs/aclpolkit.html.in b/docs/aclpolkit.html.in index 1a09139..91b5296 100644 --- a/docs/aclpolkit.html.in +++ b/docs/aclpolkit.html.in @@ -303,7 +303,7 @@ /p -h2a name=checksWriting acces control policies/a/h2 +h2a name=checksWriting access control policies/a/h2 p If using versions of polkit prior to 0.106 then it is only -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Changing test_driver.c file
Hi All, For some testing purpose I've changed some content in src/test/test_driver.c and then used make command to compile and build the code. Then I copied the libvirt.so.0.9.10.so file to the target machine and restart the libvirtd daemon, but the changes I made in test_driver.c is nothing reflected. I'm not sure whether I'm missing something. Is it moving only the libvirt.so.0.9.10.so is enough or I need to move some .a files ? , but I'm not seeing any .a in the kvm host related to libvirt to replace. Please provide me sufficient info to proceed further. Thanks In Advance, Arun V -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Changing test_driver.c file
[no need to post to two separate lists; this is a development question, so replies can drop libvirt-users] On 10/04/2013 12:08 PM, Arun Viswanath wrote: Hi All, For some testing purpose I've changed some content in src/test/test_driver.c and then used make command to compile and build the code. Then I copied the libvirt.so.0.9.10.so file to the target Huh? Why are you building 0.9.10 instead of the latest 1.1.3? machine and restart the libvirtd daemon, but the changes I made in test_driver.c is nothing reflected. I'm not sure whether I'm missing something. Is it moving only the libvirt.so.0.9.10.so is enough or I need to move some .a files ? , but I'm not seeing any .a in the kvm host related to libvirt to replace. Please provide me sufficient info to proceed further. What configure options did you use when you built libvirt? Manually copying single files onto a target machine is almost always wrong; much better is to 'make install' (perhaps with an appropriate DESTDIR=/staging setting), then place that entire installed tree into place on the destination. If you are using a Fedora-based distro, 'make rpm' will even turn your self-built binary into an rpm that you can install using your package manager, for much easier control over getting everything right. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] build: move readline check into its own macro
A future patch will allow disabling readline; doing this in an isolated file instead of configure.ac will make the task easier. * configure.ac: Move readline code... * m4/virt-readline.m4: ...here. Signed-off-by: Eric Blake ebl...@redhat.com --- configure.ac| 43 +++ m4/virt-readline.m4 | 65 + 2 files changed, 68 insertions(+), 40 deletions(-) create mode 100644 m4/virt-readline.m4 diff --git a/configure.ac b/configure.ac index 40e2210..7e357c4 100644 --- a/configure.ac +++ b/configure.ac @@ -237,6 +237,7 @@ LIBVIRT_CHECK_NETCF LIBVIRT_CHECK_NUMACTL LIBVIRT_CHECK_OPENWSMAN LIBVIRT_CHECK_PCIACCESS +LIBVIRT_CHECK_READLINE LIBVIRT_CHECK_SANLOCK LIBVIRT_CHECK_SASL LIBVIRT_CHECK_SELINUX @@ -1565,45 +1566,7 @@ fi AM_CONDITIONAL([WITH_PHYP],[test $with_phyp = yes]) dnl virsh libraries -AC_CHECK_HEADERS([readline/readline.h]) - -# Check for readline. -AC_CHECK_LIB([readline], [readline], - [lv_use_readline=yes; VIRSH_LIBS=$VIRSH_LIBS -lreadline], - [lv_use_readline=no]) - -# If the above test failed, it may simply be that -lreadline requires -# some termcap-related code, e.g., from one of the following libraries. -# See if adding one of them to LIBS helps. -if test $lv_use_readline = no; then -lv_saved_libs=$LIBS -LIBS= -AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib]) -case $LIBS in - no*) ;; # handle no and none required - *) # anything else is a -lLIBRARY - # Now, check for -lreadline again, also using $LIBS. - # Note: this time we use a different function, so that - # we don't get a cached no result. - AC_CHECK_LIB([readline], [rl_initialize], - [lv_use_readline=yes -VIRSH_LIBS=$VIRSH_LIBS -lreadline $LIBS],, - [$LIBS]) - ;; -esac -test $lv_use_readline = no - AC_MSG_WARN([readline library not found]) -LIBS=$lv_saved_libs -fi - -if test $lv_use_readline = yes; then -AC_DEFINE_UNQUOTED([USE_READLINE], 1, - [whether virsh can use readline]) -READLINE_CFLAGS=-DUSE_READLINE -else -READLINE_CFLAGS= -fi -AC_SUBST([READLINE_CFLAGS]) +VIRSH_LIBS=$VIRSH_LIBS $READLINE_LIBS AC_SUBST([VIRSH_LIBS]) dnl check if the network driver should be compiled @@ -2738,6 +2701,7 @@ LIBVIRT_RESULT_NETCF LIBVIRT_RESULT_NUMACTL LIBVIRT_RESULT_OPENWSMAN LIBVIRT_RESULT_PCIACCESS +LIBVIRT_RESULT_READLINE LIBVIRT_RESULT_SANLOCK LIBVIRT_RESULT_SASL LIBVIRT_RESULT_SELINUX @@ -2818,7 +2782,6 @@ AC_MSG_NOTICE([]) AC_MSG_NOTICE([Debug: $enable_debug]) AC_MSG_NOTICE([ Use -Werror: $set_werror]) AC_MSG_NOTICE([Warning Flags: $WARN_CFLAGS]) -AC_MSG_NOTICE([ Readline: $lv_use_readline]) AC_MSG_NOTICE([ Python: $with_python]) AC_MSG_NOTICE([ DTrace: $with_dtrace]) AC_MSG_NOTICE([numad: $with_numad]) diff --git a/m4/virt-readline.m4 b/m4/virt-readline.m4 new file mode 100644 index 000..8f5a884 --- /dev/null +++ b/m4/virt-readline.m4 @@ -0,0 +1,65 @@ +dnl The readline library +dnl +dnl Copyright (C) 2005-2013 Red Hat, Inc. +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl http://www.gnu.org/licenses/. +dnl + +AC_DEFUN([LIBVIRT_CHECK_READLINE],[ + READLINE_LIBS= + AC_CHECK_HEADERS([readline/readline.h]) + + AC_CHECK_LIB([readline], [readline], + [lv_use_readline=yes; READLINE_LIBS=-lreadline], + [lv_use_readline=no]) + + # If the above test failed, it may simply be that -lreadline requires + # some termcap-related code, e.g., from one of the following libraries. + # See if adding one of them to LIBS helps. + if test $lv_use_readline = no; then +lv_saved_libs=$LIBS +LIBS= +AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib]) +case $LIBS in + no*) ;; # handle no and none required + *) # anything else is a -lLIBRARY + # Now, check for -lreadline again, also using $LIBS. + # Note: this time we use a different function, so that + # we don't get a cached no result. + AC_CHECK_LIB([readline], [rl_initialize], + [lv_use_readline=yes +READLINE_LIBS=-lreadline $LIBS],, + [$LIBS]) + ;; +esac +test $lv_use_readline = no + AC_MSG_WARN([readline library not
[libvirt] [PATCH 0/2] Make it easier to disable readline
Previously, disabling readline involved uninstalling the development library, or else configuring with: ac_cv_lib_readline_readline=no ac_cv_search_tgetent=no ac_cv_lib_readline_rl_initialize=no With this series, it is much easier to test that virsh still works without readline support, merely using ./configuire --without-readline. Eric Blake (2): build: move readline check into its own macro build: add configure --without-readline configure.ac| 43 +++ m4/virt-readline.m4 | 50 ++ tools/virsh.c | 12 ++-- 3 files changed, 59 insertions(+), 46 deletions(-) create mode 100644 m4/virt-readline.m4 -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] build: add configure --without-readline
Make it much easier to test a configuration built without readline support, by reusing our existing library probe machinery. It gets a bit tricky with readline, which does not provide a pkg-config snippet, and which on some platforms requires one of several terminal libraries as a prerequiste, but the end result should be the same default behavior but now with the option to disable things. * m4/virt-readline.m4 (LIBVIRT_CHECK_READLINE): Simplify by using LIBVIRT_CHECK_LIB. * tools/virsh.c: Convert USE_READLINE to WITH_READLINE. Signed-off-by: Eric Blake ebl...@redhat.com --- m4/virt-readline.m4 | 51 ++- tools/virsh.c | 12 ++-- 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/m4/virt-readline.m4 b/m4/virt-readline.m4 index 8f5a884..775c186 100644 --- a/m4/virt-readline.m4 +++ b/m4/virt-readline.m4 @@ -18,48 +18,33 @@ dnl http://www.gnu.org/licenses/. dnl AC_DEFUN([LIBVIRT_CHECK_READLINE],[ - READLINE_LIBS= - AC_CHECK_HEADERS([readline/readline.h]) - - AC_CHECK_LIB([readline], [readline], - [lv_use_readline=yes; READLINE_LIBS=-lreadline], - [lv_use_readline=no]) - - # If the above test failed, it may simply be that -lreadline requires - # some termcap-related code, e.g., from one of the following libraries. - # See if adding one of them to LIBS helps. - if test $lv_use_readline = no; then -lv_saved_libs=$LIBS + extra_LIBS= + lv_saved_libs=$LIBS + if test x$with_readline != xno; then +# Linking with -lreadline may require some termcap-related code, e.g., +# from one of the following libraries. Add it to LIBS before using +# canned library checks; then verify later if it was needed. LIBS= AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib]) case $LIBS in no*) ;; # handle no and none required *) # anything else is a -lLIBRARY - # Now, check for -lreadline again, also using $LIBS. - # Note: this time we use a different function, so that - # we don't get a cached no result. - AC_CHECK_LIB([readline], [rl_initialize], - [lv_use_readline=yes -READLINE_LIBS=-lreadline $LIBS],, - [$LIBS]) - ;; + extra_LIBS=$LIBS ;; esac -test $lv_use_readline = no - AC_MSG_WARN([readline library not found]) -LIBS=$lv_saved_libs +LIBS=$lv_saved_libs $extra_LIBS fi - if test $lv_use_readline = yes; then -AC_DEFINE_UNQUOTED([USE_READLINE], 1, - [whether virsh can use readline]) -READLINE_CFLAGS=-DUSE_READLINE - else -READLINE_CFLAGS= - fi - AC_SUBST([READLINE_CFLAGS]) + # The normal library check... + LIBVIRT_CHECK_LIB([READLINE], [readline], [readline], [readline/readline.h]) + + # Touch things up to avoid $extra_LIBS, if possible. Test a second + # function, to ensure we aren't being confused by caching. + LIBS=$lv_saved_libs + AC_CHECK_LIB([readline], [rl_initialize], +[], [READLINE_LIBS=$READLINE_LIBS $extra_LIBS]) + LIBS=$lv_saved_libs ]) AC_DEFUN([LIBVIRT_RESULT_READLINE],[ - LIBVIRT_RESULT([readline], [$lv_use_readline], - [CFLAGS='$READLINE_CFLAGS' LIBS='$READLINE_LIBS']) + LIBVIRT_RESULT_LIB([READLINE]) ]) diff --git a/tools/virsh.c b/tools/virsh.c index ac354ac..6842ed8 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -48,7 +48,7 @@ #include libxml/xpath.h #include libxml/xmlsave.h -#ifdef HAVE_READLINE_READLINE_H +#if WITH_READLINE # include readline/readline.h # include readline/history.h #endif @@ -2580,7 +2580,7 @@ vshCloseLogFile(vshControl *ctl) } } -#ifdef USE_READLINE +#if WITH_READLINE /* - * Readline stuff @@ -2765,7 +2765,7 @@ vshReadline(vshControl *ctl ATTRIBUTE_UNUSED, const char *prompt) return readline(prompt); } -#else /* !USE_READLINE */ +#else /* !WITH_READLINE */ static int vshReadlineInit(vshControl *ctl ATTRIBUTE_UNUSED) @@ -2799,7 +2799,7 @@ vshReadline(vshControl *ctl, const char *prompt) return vshStrdup(ctl, r); } -#endif /* !USE_READLINE */ +#endif /* !WITH_READLINE */ static void vshDeinitTimer(int timer ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED) @@ -3026,7 +3026,7 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED) #ifdef WITH_DTRACE_PROBES vshPrint(ctl, DTrace); #endif -#ifdef USE_READLINE +#if WITH_READLINE vshPrint(ctl, Readline); #endif #ifdef WITH_DRIVER_MODULES @@ -3316,7 +3316,7 @@ main(int argc, char **argv) if (ctl-cmdstr == NULL) break; /* EOF */ if (*ctl-cmdstr) { -#if USE_READLINE +#if WITH_READLINE add_history(ctl-cmdstr); #endif if (vshCommandStringParse(ctl, ctl-cmdstr)) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [sandbox PATCH] virt-sandbox patch to launch containers with proper label
virt-sandbox should be launching containers based off the lxc_context file from selinux-policy. I changed the hard coded paths to match the latest fedora assigned labels. Fedora 20 SELinux Policy and beyond will have proper SELinux labels in its lxc_contexts file. --- bin/virt-sandbox-service | 34 ++-- bin/virt-sandbox-service-clone.pod| 5 +-- bin/virt-sandbox-service-create.pod | 16 +--- bin/virt-sandbox.c| 5 +-- libvirt-sandbox/libvirt-sandbox-builder.c | 68 +-- 5 files changed, 101 insertions(+), 27 deletions(-) diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service index c4c4f54..0bfadfe 100755 --- a/bin/virt-sandbox-service +++ b/bin/virt-sandbox-service @@ -114,12 +114,32 @@ class Container: else: self.name = name self.dest = %s/%s % (self.path, self.name) -self.file_type = self.SELINUX_FILE_TYPE +self.init_selinux_types() +self.file_type = self.get_selinux_file_type() self.conn = None self.image = None self.uid = 0 self.mounts = [] +def init_selinux_types(self): +self.selinux_dict={} +fd = open(selinux.selinux_lxc_contexts_path(),r) +records = fd.readlines() +fd.close() +for l in records: +try: +(name, val) = l.split(=) +self.selinux_dict[name.strip()]=val.strip() +except ValueError: +pass + +def get_selinux_file_type(self): +try: +return self.selinux_dict[file].split(:)[2] +except KeyError: +pass +return self.SELINUX_FILE_TYPE + def get_file_type(self): return self.file_type @@ -1072,9 +1092,17 @@ def default_security_opts(): if selinux is None: return None -# XXX vary per URI for kvm/qemu/lxc. +label = system_u:system_r:svirt_lxc_net_t:s0 # XXX generate a random category -return static,label=system_u:system_r:svirt_lxc_net_t:s0 +try: +for uri in (lxc, qemu, kvm): +if self.uri.startswith(uri): +label = self.selinux_dict[uri] +break + +except KeyError: +pass +return static,label=%s % label def gen_create_args(subparser): parser = subparser.add_parser(create, diff --git a/bin/virt-sandbox-service-clone.pod b/bin/virt-sandbox-service-clone.pod index cd261c4..3b4ecec 100644 --- a/bin/virt-sandbox-service-clone.pod +++ b/bin/virt-sandbox-service-clone.pod @@ -42,8 +42,7 @@ separated by commas. The following options are valid for SELinux Dynamically allocate an SELinux label, using the default base context. The default base context is system_u:system_r:svirt_lxc_net_t:s0 for LXC, -system_u:system_r:svirt_t:s0 for KVM, system_u:system_r:svirt_tcg_t:s0 -for QEMU. +system_u:system_r:svirt_qemu_net_t:s0 for KVM or QEMU. =item dynamic,label=USER:ROLE:TYPE:LEVEL @@ -53,7 +52,7 @@ USER:ROLE:TYPE:LEVEL, instead of the default base context. =item static,label=USER:ROLE:TYPE:LEVEL To set a completely static label. For example, -static,label=system_u:system_r:svirt_t:s0:c412,c355 +static,label=system_u:system_r:svirt_lxc_net_t:s0:c412,c355 =back diff --git a/bin/virt-sandbox-service-create.pod b/bin/virt-sandbox-service-create.pod index 2ab289a..cbfd73d 100644 --- a/bin/virt-sandbox-service-create.pod +++ b/bin/virt-sandbox-service-create.pod @@ -61,7 +61,7 @@ Default: CLogin GID of UID. Set SELinux file type to use within container. -Default: Csvirt_lxc_file_t. +Default: Csvirt_sandbox_file_t. =item B-p PATH, B--path PATH @@ -180,10 +180,14 @@ separated by commas. The following options are valid for SELinux =item dynamic -Dynamically allocate an SELinux label, using the default base context. -The default base context is system_u:system_r:svirt_lxc_net_t:s0 for LXC, -system_u:system_r:svirt_t:s0 for KVM, system_u:system_r:svirt_tcg_t:s0 -for QEMU. +Dynamically allocate an SELinux label, using the default base context for the connection URI: +The default base context are: + +BLXC = system_u:system_r:svirt_lxc_net_t:s0 + +BKVM = system_u:system_r:svirt_kvm_net_t:s0 + +BQEMU = system_u:system_r:svirt_qemu_net_t:s0 =item dynamic,label=USER:ROLE:TYPE:LEVEL @@ -193,7 +197,7 @@ USER:ROLE:TYPE:LEVEL, instead of the default base context. =item static,label=USER:ROLE:TYPE:LEVEL To set a completely static label. For example, -static,label=system_u:system_r:svirt_t:s0:c412,c355 +static,label=system_u:system_r:svirt_lxc_net_t:s0:c412,c355 =back diff --git a/bin/virt-sandbox.c b/bin/virt-sandbox.c index b16217b..f66b045 100644 --- a/bin/virt-sandbox.c +++ b/bin/virt-sandbox.c @@ -413,8 +413,7 @@ separated by commas. The following options are valid for SELinux Dynamically allocate an SELinux label, using the default base context. The default base context is
[libvirt] Second pass at patch to get different SELinux Labels for virt-sandbox
selinux-policy-3.12.1-87.fc21 selinux-policy-3.12.1-87.fc20 Now have lxc_contexts files that look like cat /etc/selinux/targeted/contexts/lxc_contexts lxc=system_u:system_r:svirt_lxc_net_t:s0 qemu=system_u:system_r:svirt_qemu_net_t:s0 kvm=system_u:system_r:svirt_qemu_net_t:s0 process=system_u:system_r:svirt_lxc_net_t:s0 file=system_u:object_r:svirt_sandbox_file_t:s0 content=system_u:object_r:virt_var_lib_t:s0 [sandbox PATCH] virt-sandbox patch to launch containers with proper -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] 1010824 - virsh suspend command should raise error for paused VM
As its summary says, BZ 1010824 requests that virsh suspend should raise error an error when called on a VM that's paused. Is the current behavior correct? Dave -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] 1010824 - virsh suspend command should raise error for paused VM
On 10/04/2013 03:21 PM, Dave Allan wrote: As its summary says, BZ 1010824 requests that virsh suspend should raise error an error when called on a VM that's paused. Is the current behavior correct? Or more importantly, would changing the behavior break backward compatibility promises, where the best we can do is just document the current behavior? -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] build: kill maintainer mode, always rebuild by default
The automake manual recommends against the use of disabling maintainer mode by default: https://www.gnu.org/software/automake/manual/automake.html#maintainer_002dmode because when it is disabled, the user gets no indication if they touch a file that would normally require a rebuild. Automake 1.11 changed things so that AM_MAINTAINER_MODE([enable]) will set the mode to enabled by default; but RHEL 5 still uses automake 1.9, where AM_MAINTAINER_MODE did not recognize an argument, and therefore disables maintainer mode by default. Having the default be different according to which version of automake built the project is annoying, and I _have_ been bitten on RHEL 5 rebuilds where the default disabled mode led to silently incorrect builds. The automake manual admits that being able to disable maintainer mode still makes sense for projects that still store generated files from the autotools in version control; but we have dropped that for several years now. As such, it's finally time to just ditch the whole idea of maintainer mode, and unconditionally rebuild autotools files if a dependency changes, without offering a configure option to disable that mode. * configure.ac (AM_MAINTAINER_MODE): Drop. Signed-off-by: Eric Blake ebl...@redhat.com --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7e357c4..024b0c8 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,6 @@ AC_CONFIG_MACRO_DIR([m4]) dnl Make automake keep quiet about wildcards other GNUmake-isms; also keep dnl quiet about the fact that we intentionally cater to automake 1.9 AM_INIT_AUTOMAKE([-Wno-portability -Wno-obsolete tar-ustar subdir-objects]) -AM_MAINTAINER_MODE([enable]) # Maintainer note - comment this line out if you plan to rerun # GNULIB_POSIXCHECK testing to see if libvirt should be using more modules. -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: be smarter about building documentation
On 09/27/2013 09:48 AM, Daniel P. Berrange wrote: On Thu, Sep 19, 2013 at 04:27:41PM -0600, Eric Blake wrote: I'm tired of cryptic reports on IRC from people who build from git, then type 'make install' and have it fail quite a ways down the road because the documentation wasn't built. It's a feature that documentation is not built during development if the toolchain is not present (not all git developers build tarballs, and the tarballs already contain pre-built docs); but this only works as long as you don't try to install or make a tarball from that setup. With this patch in place, and without xhtml1-dtds, I now get this nice failure: $ make install cfg.mk:109: *** ERROR: missing doc toolchain (install xhtml1-dtds and xmllint). Stop. Can't we just make our existing rules fatal. I really don't see the point in treating docs errors as non-fatal. If the docs are not built, or are outdated, we should try to build them and fail if the tools aren't present. This matches my reasoning behind my patch to ditch automake's maintainer mode: https://www.redhat.com/archives/libvir-list/2013-October/msg00226.html We already require libxml.so be present, so requiring the libxml/libxslt cli tools really isn't a burden in the great scheme of things. xsltproc and xmllint are easy to come by (it seems that every distro has a way to download them), but having the xhtml dtds is a bit harder (I couldn't find whether FreeBSD supports them by default, and I know that cygwin does not have them available in the distro yet). I can easily make bootstrap fail if the tools aren't present, but I don't know how to make it fail if the dtds are missing. On the other hand, I also just proved to myself that it is fairly easy to get the dtds set up in a local catalog. A single wget of 4 files from w3c, followed by a few xmlcatalog calls, is sufficient: cd docs wget http://www.w3.org/TR/xhtml1/DTD/xhtml{1-strict.dtd,-{lat1,special,symbol}.ent} xmlcatalog --noout --create catalog xmlcatalog --noout --add public -//W3C//DTD XHTML 1.0 Strict//EN xhtml1-strict.dtd catalog xmlcatalog --noout --add public -//W3C//ENTITIES Latin 1 for XHTML//EN xhtml-lat1.dtd catalog xmlcatalog --noout --add public -//W3C//ENTITIES Special for XHTML//EN xhtml-special.dtd catalog xmlcatalog --noout --add public -//W3C//ENTITIES Symbols for XHTML//EN xhtml-symbol.dtd catalog cd .. ./configure --with-xml-catalog-file=$PWD/docs/catalog Would it be appropriate to create a local catalog on any system where xhtml1-dtds is not already present as part of the distro, during the bootstrap phase, to make it much easier to continue to build from git on FreeBSD and Cygwin? IOW, we should remove all the @if test -x $(XMLLINT) test -x $(XMLCATALOG) ; then \ @if [ -x $(XSLTPROC) ] ; then \ conditionals, and just let 'make' do its normal deps calculation and errore reporting. Yes, I'd still like to do this, but only if I can get consensus on how to handle development on platforms that don't ship xhtml dtds in an easy-to-access distro location. As long as the docs are included in the tar.gz people building fro mthe tar.gz will still not build the docs. Yes, I still plan on ensuring that this works. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: fix build --without-remote
On 10/04/2013 12:19 AM, Michal Privoznik wrote: On 28.09.2013 04:55, Eric Blake wrote: I tried to test ./configure --without-lxc --without-remote. First, the build failed with some odd errors, such as an inability to build xen, or link failures for virNetTLSInit. But when you think about it, once there is no remote code, all of libvirtd is useless, any stateful driver that depends on libvirtd is also not worth compiling, and any libraries used only by RPC code are not needed. So I patched configure.ac to make for some saner defaults when an explicit disable is attempted. Similarly, since we have migrated virnetdevbridge into generic code, the workaround for Linux kernel stupidity must not depend on stateful drivers being in use. ACK Although I get this error when running 'make check'. Not a show stopper - this patch fixes the build (I'm able to build --without-remote now), but would be nice if you can get rid of it too. Making check in src make[1]: Entering directory `/home/zippy/work/libvirt/libvirt.git/src' make check-am make[2]: Entering directory `/home/zippy/work/libvirt/libvirt.git/src' make check-local make[3]: Entering directory `/home/zippy/work/libvirt/libvirt.git/src' GEN check-symfile GEN check-symsorting GEN check-drivername GEN check-driverimpls Can't open ./remote/remote_protocol.c: No such file or directory at ./check-driverimpls.pl line 29, line 140903. Eww - that's what I get for testing in an incremental tree, rather than a fresh clone. I'll clean that up as a separate patch. Meanwhile, I've pushed this one. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] build: fix build on RHEL 5
On RHEL 5, compilation fails with: storage/storage_backend.c: In function 'createRawFile': storage/storage_backend.c:339: warning: implicit declaration of function 'fallocate' storage/storage_backend.c:339: warning: nested extern declaration of 'fallocate' [-Wnested-externs] But: $ grep HAVE_FALLOCATE config.h /* #undef HAVE_FALLOCATE */ Huh? It turns out that in kernels that old, fallocate() is not implemented (config.h is correct), but linux/fs.h defines HAVE_FALLOCATE as an empty witness macro for a completely different purpose. Since storage_backend.c is including linux/fs.h on RHEL 5, we are hosed by the kernel definition. Newer kernels no longer pollute the namespace, and it's fairly easy to convert to an expression that works with both the old kernel witness and the new-style config.h (undefined or 1). Problem introduced in commit 532fef3. * src/storage/storage_backend.c (createRawFile): Avoid namespace pollution from kernel, by checking HAVE_FALLOCATE for a value. Signed-off-by: Eric Blake ebl...@redhat.com --- Pushing under the build-breaker rule. src/storage/storage_backend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 5f1bc66..662af32 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -329,7 +329,8 @@ createRawFile(int fd, virStorageVolDefPtr vol, goto cleanup; } -#ifdef HAVE_FALLOCATE +/* Avoid issues with older kernel's linux/fs.h namespace pollution. */ +#if HAVE_FALLOCATE - 0 /* Try to preallocate all requested disk space, but fall back to * other methods if this fails with ENOSYS or EOPNOTSUPP. * NOTE: do not use posix_fallocate; posix_fallocate falls back -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] build: fix build on 32-bit platforms
qemumonitorjsontest.c: In function 'testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo': qemumonitorjsontest.c:1134: warning: integer constant is too large for 'long' type * tests/qemumonitorjsontest.c (testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo) (testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo): Use correct type. Signed-off-by: Eric Blake ebl...@redhat.com --- Pushing under the build-breaker rule. tests/qemumonitorjsontest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 026beee..cd83592 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1131,7 +1131,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo(const void *data) if (qemuMonitorJSONGetBalloonInfo(qemuMonitorTestGetMonitor(test), currmem) 0) goto cleanup; -if (currmem != (4294967296/1024)) { +if (currmem != (4294967296ULL/1024)) { virReportError(VIR_ERR_INTERNAL_ERROR, Unexpected currmem value: %llu, currmem); goto cleanup; @@ -1389,7 +1389,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data) extent) 0) goto cleanup; -if (extent != 5256018944) { +if (extent != 5256018944ULL) { virReportError(VIR_ERR_INTERNAL_ERROR, Invalid extent: %llu, expected 5256018944, extent); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list