Re: [libvirt] [PATCH 3/3] scsi: Adjust return status from getBlockDevice
On 06/15/2015 07:24 AM, Michal Privoznik wrote: From: John Ferlan jfer...@redhat.com https://bugzilla.redhat.com/show_bug.cgi?id=1224233 Currently it's not possible to determine the difference between a fatal memory allocation or failure to open/read the directory error with a perhaps less fatal, I didn't find the block device in the directory (which may be a disk entry without a block device). In the case of the latter, we shouldn't cause failure to continue searching in the caller (virStorageBackendSCSIFindLUs), rather we should allow trying reading the next directory entry. Signed-off-by: John Ferlan jfer...@redhat.com Signed-off-by: Michal Privoznik mpriv...@redhat.com --- src/storage/storage_backend_scsi.c | 48 +++--- 1 file changed, 34 insertions(+), 14 deletions(-) ACK - I had assumed only 1 2 were adjustments and felt odd acking my own change, but now I see that there were more changes here as well... John diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index ddfbade..b426145 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -324,6 +324,15 @@ getOldStyleBlockDevice(const char *lun_path ATTRIBUTE_UNUSED, } +/* + * Search a device entry for the block file + * + * Returns + * + * 0 = Found it + * -1 = Fatal error + * -2 = Didn't find in lun_path directory + */ static int getBlockDevice(uint32_t host, uint32_t bus, @@ -337,36 +346,47 @@ getBlockDevice(uint32_t host, int retval = -1; int direrr; +*block_device = NULL; + if (virAsprintf(lun_path, /sys/bus/scsi/devices/%u:%u:%u:%u, host, bus, target, lun) 0) -goto out; +goto cleanup; -lun_dir = opendir(lun_path); -if (lun_dir == NULL) { +if (!(lun_dir = opendir(lun_path))) { virReportSystemError(errno, _(Failed to opendir sysfs path '%s'), lun_path); -goto out; +goto cleanup; } while ((direrr = virDirRead(lun_dir, lun_dirent, lun_path)) 0) { if (STREQLEN(lun_dirent-d_name, block, 5)) { if (strlen(lun_dirent-d_name) == 5) { -retval = getNewStyleBlockDevice(lun_path, -lun_dirent-d_name, -block_device); +if (getNewStyleBlockDevice(lun_path, + lun_dirent-d_name, + block_device) 0) +goto cleanup; } else { -retval = getOldStyleBlockDevice(lun_path, -lun_dirent-d_name, -block_device); +if (getOldStyleBlockDevice(lun_path, + lun_dirent-d_name, + block_device) 0) +goto cleanup; } break; } } +if (direrr 0) +goto cleanup; +if (!*block_device) { +retval = -2; +goto cleanup; +} -closedir(lun_dir); +retval = 0; - out: + cleanup: +if (lun_dir) +closedir(lun_dir); VIR_FREE(lun_path); return retval; } @@ -412,9 +432,9 @@ processLU(virStoragePoolObjPtr pool, VIR_DEBUG(%u:%u:%u:%u is a Direct-Access LUN, host, bus, target, lun); -if (getBlockDevice(host, bus, target, lun, block_device) 0) { +if ((retval = getBlockDevice(host, bus, target, lun, block_device)) 0) { VIR_DEBUG(Failed to find block device for this LUN); -return -1; +return retval; } retval = virStorageBackendSCSINewLun(pool, host, bus, target, lun, -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [CFT][PATCH 00/10] Making new mounts of proc and sysfs as safe as bind mounts (take 2)
Am 16.06.2015 um 14:31 schrieb Daniel P. Berrange: Thanks Richard / Eric for the suggested patches. I'll apply Eric's simplified patch to libvirt now, and backport it to our stable libvirt branches. Thank you Daniel! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Socket files in virt-aa-helper
Hi all, May I kindly ask someone for some advice on this topic? Regards, Michal On 21 May 2015 at 20:23, Michał Dubiel m...@semihalf.com wrote: Hi guys, I have got a question. I need to add apparmor support for vhost-user socket files used to communicate with the vhost-user server app. Those ones defined with something like: interface type='vhostuser' mac address='02:ed:f3:5d:de:f3'/ source type='unix' path='/var/run/vrouter/uvh_vif_tapa8396c51-2a' mode='client'/ model type='virtio'/ address type='pci' domain='0x' bus='0x00' slot='0x03' function='0x0'/ /interface I added something like this into get_files() function in virt-aa-helper.c: for (i = 0; i ctl-def-nnets; i++) { if (ctl-def-nets[i] ctl-def-nets[i]-type == VIR_DOMAIN_NET_TYPE_VHOSTUSER ctl-def-nets[i]-data.vhostuser) { virDomainChrSourceDefPtr vhu = ctl-def-nets[i]-data.vhostuser; if (vah_add_file_chardev(buf, vhu-data.nix.path, rw, vhu-type) != 0) goto cleanup; } } However, there is a restriction for the socket file types in valid_path() function: switch (sb.st_mode S_IFMT) { case S_IFSOCK: return 1; break; default: break; } That prevents this from working. May I ask why the socket file types are restricted? Vhost-user uses sockets so if I want to use apparmor virt-aa-helper has to be able to add the line for the socket file into /etc/apparmor.d/libvirt/libvirt-UUID.files. Regards, Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 0/3] Fix and tweak 'uknown cause' error in virDirCreate
On 06/16/2015 04:23 PM, Ján Tomko wrote: On Tue, Jun 16, 2015 at 02:28:52PM +0200, Erik Skultety wrote: Erik Skultety (3): util: virfile: Fix 'unknown cause' error if NFS mount point creation fails util: virDirCreate: Child now exits with positive errno-code virfile: virDirCreate: Insert blank lines to assure slightly better readability ACK series if you exchange the first two patches. Both the original logic assume the exit status to be +errno, not -errno, so that change should be first. Jan Thank you, patches are now pushed. Erik -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCH] Change livbirt version to 1.3.0 for the next release
Since the background for Admin API is merged upstream, we are bumping the minor release version as discussed previously Signed-off-by: Martin Kletzander mklet...@redhat.com --- Pushed as trivial setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8d34fde3e60d..04e3de41fc71 100755 --- a/setup.py +++ b/setup.py @@ -311,7 +311,7 @@ class my_clean(clean): _c_modules, _py_modules = get_module_lists() setup(name = 'libvirt-python', - version = '1.2.17', + version = '1.3.0', url = 'http://www.libvirt.org', maintainer = 'Libvirt Maintainers', maintainer_email = 'libvir-list@redhat.com', -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 0/3] Fix and tweak 'uknown cause' error in virDirCreate
On Tue, Jun 16, 2015 at 02:28:52PM +0200, Erik Skultety wrote: Erik Skultety (3): util: virfile: Fix 'unknown cause' error if NFS mount point creation fails util: virDirCreate: Child now exits with positive errno-code virfile: virDirCreate: Insert blank lines to assure slightly better readability ACK series if you exchange the first two patches. Both the original logic assume the exit status to be +errno, not -errno, so that change should be first. Jan signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/3] util: virfile: Fix 'unknown cause' error if NFS mount point creation fails
This happens if user requires creation of a directory with specified UID/GID permissions. To accomplish this, we use fork approach and set particular UID/GID permissions in child process. However, child process doesn't have a valid descriptor to a logfile (this is prohibited explicitly) and since parent process doesn't handle negative exit codes from child in any way, 'uknown cause' error is returned to the user. Commit 92d9114e tweaked the way we handle child errors when using fork approach to set specific permissions (features originally introduced by 98f6f381). The same logic should be used to create directories with specified permissions as well. https://bugzilla.redhat.com/show_bug.cgi?id=1230137 --- src/util/virfile.c | 24 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 5ff4668..5e678fe 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2384,11 +2384,27 @@ virDirCreate(const char *path, path); goto parenterror; } -if (!WIFEXITED(status) || (ret = -WEXITSTATUS(status)) == -EACCES) { -/* fall back to the simpler method, which works better in - * some cases */ -return virDirCreateNoFork(path, mode, uid, gid, flags); + +/* + * If waitpid succeeded, but if the child exited abnormally or + * reported non-zero status, report failure, except for EACCES where + * we try to fall back to non-fork method as in the original logic + * introduced and explained by commit 98f6f381. + */ +if (!WIFEXITED(status) || (WEXITSTATUS(status)) != 0) { +if (WEXITSTATUS(status) == EACCES) +return virDirCreateNoFork(path, mode, uid, gid, flags); +char *msg = virProcessTranslateStatus(status); +virReportError(VIR_ERR_INTERNAL_ERROR, + _(child failed to create '%s': %s), + path, msg); +VIR_FREE(msg); +if (WIFEXITED(status)) +ret = -WEXITSTATUS(status); +else +ret = -EACCES; } + parenterror: return ret; } -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] util: Fix Coverity RESOURCE_LEAK
Commit id 'e44b0269c9' in advertently checked !dir before calling closedir Signed-off-by: John Ferlan jfer...@redhat.com --- Pushed as trivial src/util/virprocess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index f1924eb..8fa7a9b 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -638,7 +638,7 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) ret = 0; cleanup: -if (!dir) +if (dir) closedir(dir); VIR_FREE(taskPath); if (ret 0) -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] nodedev-dumpxml doesn't refresh supported offload NIC capabilities
Hi, I was playing with the nodedev-dumpxml to see the supported offload NIC capabilities, and It seem that if I disable one of offloading capabilities using ethtool command nodedev-dumpxml it still return the feature as enabled. To get the correct offloading capabilities I have to restart libvirtd. I was wandering if that is an expected behavior in lbivirt . Please see example below with the rx capabilities disabled. virsh # nodedev-dumpxml net_enp4s0_f4_52_14_11_73_81 device namenet_enp4s0_f4_52_14_11_73_81/name path/sys/devices/pci:00/:00:02.0/:04:00.0/net/enp4s0/path parentpci__04_00_0/parent capability type='net' interfaceenp4s0/interface addressf4:52:14:11:73:81/address link speed='4' state='up'/ feature name='rx'/ feature name='tx'/ feature name='sg'/ feature name='tso'/ feature name='gso'/ feature name='gro'/ feature name='rxvlan'/ feature name='txvlan'/ feature name='rxhash'/ capability type='80203'/ /capability /device ethtool -K enp4s0 rx off virsh # nodedev-dumpxml net_enp4s0_f4_52_14_11_73_81 device namenet_enp4s0_f4_52_14_11_73_81/name path/sys/devices/pci:00/:00:02.0/:04:00.0/net/enp4s0/path parentpci__04_00_0/parent capability type='net' interfaceenp4s0/interface addressf4:52:14:11:73:81/address link speed='4' state='up'/ feature name='rx'/ feature name='tx'/ feature name='sg'/ feature name='tso'/ feature name='gso'/ feature name='gro'/ feature name='rxvlan'/ feature name='txvlan'/ feature name='rxhash'/ capability type='80203'/ /capability /device virsh # [root@r-ae-host05 bin]# ps -ef | grep libvirt root 16743 23086 0 16:43 pts/200:00:00 ../sbin/libvirtd root 17440 23086 0 16:47 pts/200:00:00 grep --color=auto libvirt [root@r-ae-host05 bin]# kill 16743 [root@r-ae-host05 bin]# ../sbin/libvirtd [2] 17489 [1] Done../sbin/libvirtd [root@r-ae-host05 bin]# [root@r-ae-host05 bin]# [root@r-ae-host05 bin]# ./virsh virsh # nodedev-dumpxml net_enp4s0_f4_52_14_11_73_81 device namenet_enp4s0_f4_52_14_11_73_81/name path/sys/devices/pci:00/:00:02.0/:04:00.0/net/enp4s0/path parentpci__04_00_0/parent capability type='net' interfaceenp4s0/interface addressf4:52:14:11:73:81/address link speed='4' state='up'/ feature name='tx'/ feature name='sg'/ feature name='tso'/ feature name='gso'/ feature name='gro'/ feature name='rxvlan'/ feature name='txvlan'/ feature name='rxhash'/ feature name='rdma'/ capability type='80203'/ /capability /device Thanks, Moshe Levi. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [glib v2 3/4] Add loop and nbd filesystem types
On Tue, Jun 16, 2015 at 10:58:13AM +0200, Cédric Bosdonnat wrote: --- libvirt-gconfig/libvirt-gconfig-domain-filesys.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h index 4f3973e..4144976 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h @@ -75,6 +75,8 @@ typedef enum { GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_PATH, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_HANDLE, +GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_LOOP, +GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD, Can you add GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_PLOOP while at it? (if you don't have libvirt commit rights, I can do that before pushing) Christophe pgpb_UFvKBYDP.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] lxc: Rename daemon to dmn
On older systems it shadows global declaration of daemon() function. Signed-off-by: Martin Kletzander mklet...@redhat.com --- Pushed as a build-breaker src/lxc/lxc_controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 5f59867408a3..828b8a8c0ee3 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -987,7 +987,7 @@ static bool wantReboot; static virMutex lock = VIR_MUTEX_INITIALIZER; -static void virLXCControllerSignalChildIO(virNetDaemonPtr daemon, +static void virLXCControllerSignalChildIO(virNetDaemonPtr dmn, siginfo_t *info ATTRIBUTE_UNUSED, void *opaque) { @@ -998,7 +998,7 @@ static void virLXCControllerSignalChildIO(virNetDaemonPtr daemon, ret = waitpid(-1, status, WNOHANG); VIR_DEBUG(Got sig child %d vs %lld, ret, (unsigned long long)ctrl-initpid); if (ret == ctrl-initpid) { -virNetDaemonQuit(daemon); +virNetDaemonQuit(dmn); virMutexLock(lock); if (WIFSIGNALED(status) WTERMSIG(status) == SIGHUP) { -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Change livbirt version to 1.3.0 for the next release
Since the background for Admin API is merged upstream, we are bumping the minor release version as discussed previously Signed-off-by: Martin Kletzander mklet...@redhat.com --- Pushed as trivial configure.ac | 2 +- docs/formatdomain.html.in| 2 +- src/parallels/parallels_driver.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index dbaf2722f8f3..20fc564a8128 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ 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/. -AC_INIT([libvirt], [1.2.17], [libvir-list@redhat.com], [], [http://libvirt.org]) +AC_INIT([libvirt], [1.3.0], [libvir-list@redhat.com], [], [http://libvirt.org]) AC_CONFIG_SRCDIR([src/libvirt.c]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3ccc71c55918..4e85b51040cb 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4275,7 +4275,7 @@ qemu-kvm -net nic,model=? /dev/null element. Each queue will potentially be handled by a different processor, resulting in much higher throughput. span class=sincevirtio-net since 1.0.6 (QEMU and KVM only)/span -span class=sincevhost-user since 1.2.17 (QEMU and KVM only)/span +span class=sincevhost-user since 1.3.0 (QEMU and KVM only)/span /dd dtcodehost/code offloading options/dt dd diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 706229d8486c..b0a19f32c820 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -1371,8 +1371,8 @@ static virHypervisorDriver vzDriver = { .domainManagedSave = parallelsDomainManagedSave, /* 1.2.14 */ .domainManagedSaveRemove = parallelsDomainManagedSaveRemove, /* 1.2.14 */ .domainGetMaxMemory = parallelsDomainGetMaxMemory, /* 1.2.15 */ -.domainBlockStats = parallelsDomainBlockStats, /* 1.2.17 */ -.domainBlockStatsFlags = parallelsDomainBlockStatsFlags, /* 1.2.17 */ +.domainBlockStats = parallelsDomainBlockStats, /* 1.3.0 */ +.domainBlockStatsFlags = parallelsDomainBlockStatsFlags, /* 1.3.0 */ }; static virConnectDriver vzConnectDriver = { -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [CFT][PATCH 00/10] Making new mounts of proc and sysfs as safe as bind mounts (take 2)
On Sat, Jun 06, 2015 at 01:56:54PM -0500, Eric W. Biederman wrote: Richard Weinberger rich...@nod.at writes: [CC'ing libvirt-lxc folks] Am 28.05.2015 um 23:32 schrieb Eric W. Biederman: Richard Weinberger rich...@nod.at writes: Am 28.05.2015 um 21:57 schrieb Eric W. Biederman: FWIW, it breaks also libvirt-lxc: Error: internal error: guest failed to start: Failed to re-mount /proc/sys on /proc/sys flags=1021: Operation not permitted Interesting. I had not anticipated a failure there? And it is failing in remount? Oh that is interesting. That implies that there is some flag of the original mount of /proc that the remount of /proc/sys is clearing, and that previously The flags specified are current rdonly,remount,bind so I expect there are some other flags on proc that libvirt-lxc is clearing by accident and we did not fail before because the kernel was not enforcing things. Please see: http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/lxc/lxc_container.c;h=9a9ae5c2aaf0f90ff472f24fda43c077b44998c7;hb=HEAD#l933 lxcContainerMountBasicFS() and: http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/lxc/lxc_container.c;h=9a9ae5c2aaf0f90ff472f24fda43c077b44998c7;hb=HEAD#l850 lxcBasicMounts What are the mount flags in a working libvirt-lxc? See: test1:~ # cat /proc/self/mountinfo 149 147 0:56 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw 150 149 0:56 /sys /proc/sys ro,nodev,relatime - proc proc rw If you need more info, please let me know. :-) Oh interesting I had not realized libvirt-lxc had grown an unprivileged mode using user namespaces. This does appear to be a classic remount bug, where you are not preserving the permissions. It appears the fact that the code failed to enforce locked permissions on the fresh mount of proc was hiding this bug until now. I expect what you actually want is the code below: diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 9a9ae5c2aaf0..f008a7484bfe 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -850,7 +850,7 @@ typedef struct { static const virLXCBasicMountInfo lxcBasicMounts[] = { { proc, /proc, proc, MS_NOSUID|MS_NOEXEC|MS_NODEV, false, false, false }, -{ /proc/sys, /proc/sys, NULL, MS_BIND|MS_RDONLY, false, false, false }, +{ /proc/sys, /proc/sys, NULL, MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false, false }, { /.oldroot/proc/sys/net/ipv4, /proc/sys/net/ipv4, NULL, MS_BIND, false, false, true }, { /.oldroot/proc/sys/net/ipv6, /proc/sys/net/ipv6, NULL, MS_BIND, false, false, true }, { sysfs, /sys, sysfs, MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false, false }, Or possibly just: diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 9a9ae5c2aaf0..a60ccbd12bfc 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -850,7 +850,7 @@ typedef struct { static const virLXCBasicMountInfo lxcBasicMounts[] = { { proc, /proc, proc, MS_NOSUID|MS_NOEXEC|MS_NODEV, false, false, false }, -{ /proc/sys, /proc/sys, NULL, MS_BIND|MS_RDONLY, false, false, false }, +{ /proc/sys, /proc/sys, NULL, MS_BIND|MS_RDONLY, true, false, false }, { /.oldroot/proc/sys/net/ipv4, /proc/sys/net/ipv4, NULL, MS_BIND, false, false, true }, { /.oldroot/proc/sys/net/ipv6, /proc/sys/net/ipv6, NULL, MS_BIND, false, false, true }, { sysfs, /sys, sysfs, MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false, false }, As the there is little point in making /proc/sys read-only in a user-namespace, as the permission checks are uid based and no-one should have the global uid 0 in your container. Making mounting /proc/sys read-only rather pointless. Eric, using the patch below I was able to spawn a user-namespace enabled container using libvirt-lxc. :-) I had to: 1. Disable the read-only mount of /proc/sys which is anyway useless in the user-namespace case. 2. Disable the /proc/sys/net/ipv{4,6} bind mounts, this ugly hack is only needed for the non user-namespace case. 3. Remove MS_RDONLY from the sysfs mount (For the non user-namespace case we'd have to keep this, though). Daniel, I'd take this as a chance to disable all the MS_RDONLY games if user-namespace are configured. With Eric's fixes they hurt us. And as I wrote many times before if root within the user-namespace is able to do nasty things in /sys and /proc that's a plain kernel bug which needs fixing. There is no point in mounting these read-only. Except for the case then no user-namespace is used. For clarity the patch below appears to be the minimal change needed to fix this security issue. AKA add mnt_mflags in when remounting something read-only. /proc/sys needed to be updated so it had the proper flags to be added back in. I hope
Re: [libvirt] [PATCH] network: add an option to make dns public
Hi Laine, On Thu, 2015-06-11 at 13:37 -0400, Laine Stump wrote: On 06/10/2015 03:56 PM, John Ferlan wrote: On 06/01/2015 07:54 AM, Cédric Bosdonnat wrote: In some use cases we don't want the virtual network's DNS to only listen to the vnet interface. Adding a publiclyAccessible attribute :-) Really, that name was only intended as a placeholder! I was hoping you (or someone else) would be able to find something shorter/simpler. Lacking that, I guess this is a reasonable name though. Given the other names around that didn't shock me, but it's surely not a good habit to introduce such lengthy names ;) to the dns element in the configuration allows the DNS to listen to all interfaces. It simply disables the bind-dynamic option of dnsmasq for the network. --- docs/formatnetwork.html.in | 11 +++ docs/schemas/network.rng | 15 ++- src/conf/network_conf.c | 6 ++ src/conf/network_conf.h | 1 + src/network/bridge_driver.c | 4 +++- tests/networkxml2confdata/nat-network-dns-hosts.conf | 1 - tests/networkxml2confdata/nat-network-dns-hosts.xml | 2 +- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in index 6abed8f..8e43658 100644 --- a/docs/formatnetwork.html.in +++ b/docs/formatnetwork.html.in @@ -851,6 +851,17 @@ DNS server. /p +p + The dns element + can have an optional codepubliclyAccessible/code + attribute span class=sinceSince 1.2.17/span. + If codepubliclyAccessible/code is yes, then the DNS server + will handle requests for all interfaces. + If codepubliclyAccessible/code is not set or no, the DNS + server will only handle requests for the interface of the virtual + network. +/p + Currently supported sub-elements of codelt;dnsgt;/code are: dl dtcodeforwarder/code/dt diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index 4edb6eb..f989625 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -244,12 +244,17 @@ and other features in the dns element -- optional element name=dns -optional - attribute name=forwardPlainNames -ref name=virYesNo/ - /attribute -/optional interleave + optional +attribute name=forwardPlainNames + ref name=virYesNo/ +/attribute + /optional + optional +attribute name=publiclyAccessible + ref name=virYesNo/ +/attribute + /optional Moving the attributes inside the interleave had me looking through other .rng's... I'm no expert, but had thought they really only mattered for element's I'm not an expert either, but you are correct :-) I'm fixing that one. zeroOrMore element name=forwarder attribute name=addrref name=ipAddr//attribute diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index f4a9df0..99bac6d 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1309,9 +1309,14 @@ virNetworkDNSDefParseXML(const char *networkName, size_t i; int ret = -1; xmlNodePtr save = ctxt-node; +char *publiclyAccessible = NULL; ctxt-node = node; +publiclyAccessible = virXPathString(string(./@publiclyAccessible), ctxt); +if (publiclyAccessible) +def-publiclyAccessible = virTristateBoolTypeFromString(publiclyAccessible); + forwardPlainNames = virXPathString(string(./@forwardPlainNames), ctxt); if (forwardPlainNames) { def-forwardPlainNames = virTristateBoolTypeFromString(forwardPlainNames); @@ -1410,6 +1415,7 @@ virNetworkDNSDefParseXML(const char *networkName, ret = 0; cleanup: +VIR_FREE(publiclyAccessible); VIR_FREE(forwardPlainNames); VIR_FREE(fwdNodes); VIR_FREE(hostNodes); diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index f69d999..f555b6b 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -136,6 +136,7 @@ struct _virNetworkDNSDef { virNetworkDNSSrvDefPtr srvs; size_t nfwds; char **forwarders; +int publiclyAccessible; /* enum virTristateBool */ }; typedef struct _virNetworkIpDef virNetworkIpDef; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index d195085..c39b1a5 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@
[libvirt] [PATCH v2] qemu: implement address for isa-serial
I needed to specify the iobase address for certain exotic mips configurations. Signed-off-by: James Cowgill james...@cowgill.org.uk --- src/qemu/qemu_command.c| 12 ++-- .../qemuxml2argv-serial-dev-chardev-iobase.args| 7 + .../qemuxml2argv-serial-dev-chardev-iobase.xml | 36 ++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml v2: - add the serial-dev-chardev-iobase testcase diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3886b4f..f63d2a1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2693,6 +2693,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, info-addr.ccw.cssid, info-addr.ccw.ssid, info-addr.ccw.devno); +} else if (info-type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { +virBufferAsprintf(buf, ,iobase=0x%x,irq=0x%x, + info-addr.isa.iobase, + info-addr.isa.irq); } ret = 0; @@ -10982,11 +10986,15 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA: -if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { +if (serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE +serial-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, - _(no addresses are supported for isa-serial)); + _(isa-serial requires address of isa type)); goto error; } + +if (qemuBuildDeviceAddressStr(cmd, def, serial-info, qemuCaps) 0) +goto error; break; case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args new file mode 100644 index 000..9d5de02 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.args @@ -0,0 +1,7 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev socket,\ +id=charmonitor,path=/tmp/test-monitor,server,nowait -mon chardev=charmonitor,\ +id=monitor,mode=readline -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -chardev \ +tty,id=charserial0,path=/dev/ttyS2 -device isa-serial,chardev=charserial0,\ +id=serial0,iobase=0x3f8,irq=0x4 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml new file mode 100644 index 000..eb84574 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev-chardev-iobase.xml @@ -0,0 +1,36 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory unit='KiB'219100/memory + currentMemory unit='KiB'219100/currentMemory + vcpu placement='static'1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +controller type='usb' index='0'/ +controller type='ide' index='0'/ +serial type='dev' + source path='/dev/ttyS2'/ + target port='0'/ + address type='isa' iobase='0x3f8' irq='0x4'/ +/serial +console type='dev' + source path='/dev/ttyS2'/ + target port='0'/ + address type='isa' iobase='0x3f8' irq='0x4'/ +/console +memballoon model='virtio'/ + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a90f9a6..56b18eb 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1045,6 +1045,8 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); DO_TEST(serial-dev-chardev, QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); +DO_TEST(serial-dev-chardev-iobase, +QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); DO_TEST(serial-file-chardev, QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); DO_TEST(serial-unix-chardev, -- 2.1.4 signature.asc Description: This is a digitally signed message
Re: [libvirt] [PATCH v2 1/2] Add virProcessGetPids to get all tasks of a process
On 06/16/2015 05:18 AM, Cédric Bosdonnat wrote: This function gets all the PIDs listed in /proc/PID/task. This will be needed at least to move all qmeu-nbd tasks to the container cgroup. --- src/libvirt_private.syms | 1 + src/util/virprocess.c| 47 +++ src/util/virprocess.h| 2 ++ 3 files changed, 50 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6a95fb9..780cfbb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1986,6 +1986,7 @@ virProcessAbort; virProcessExitWithStatus; virProcessGetAffinity; virProcessGetNamespaces; +virProcessGetPids; virProcessGetStartTime; virProcessKill; virProcessKillPainfully; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 7a79970..ce5e106 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -608,6 +608,53 @@ int virProcessGetAffinity(pid_t pid ATTRIBUTE_UNUSED, #endif /* HAVE_SCHED_GETAFFINITY */ +int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) +{ +int ret = -1; +char *taskPath = NULL; +DIR *dir = NULL; +int value; +struct dirent *ent; + +*npids = 0; +*pids = NULL; + +if (virAsprintf(taskPath, /proc/%llu/task, +(unsigned long long)pid) 0) +goto cleanup; + +if (!(dir = opendir(taskPath))) +goto cleanup; + +while ((value = virDirRead(dir, ent, taskPath)) 0) { +pid_t tmp_pid; + +/* Skip . and .. */ +if (STRPREFIX(ent-d_name, .)) +continue; + +if (virStrToLong_i(ent-d_name, NULL, 10, tmp_pid) 0) +goto cleanup; + +if (VIR_APPEND_ELEMENT(*pids, *npids, tmp_pid) 0) +goto cleanup; +} + +if (value 0) +goto cleanup; + +ret = 0; + + cleanup: +if (!dir) +closedir(dir); ^^ Coverity got grumpy about a RESOURCE_LEAK here. I'll fix and push the obvious 1 character less patch John +VIR_FREE(taskPath); +if (ret 0) +VIR_FREE(*pids); +return ret; +} + + int virProcessGetNamespaces(pid_t pid, size_t *nfdlist, int **fdlist) diff --git a/src/util/virprocess.h b/src/util/virprocess.h index c812882..86a633d 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -62,6 +62,8 @@ int virProcessGetAffinity(pid_t pid, virBitmapPtr *map, int maxcpu); +int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids); + int virProcessGetStartTime(pid_t pid, unsigned long long *timestamp); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [glib v2 3/4] Add loop and nbd filesystem types
On Tue, 2015-06-16 at 14:43 +0200, Christophe Fergeau wrote: On Tue, Jun 16, 2015 at 10:58:13AM +0200, Cédric Bosdonnat wrote: --- libvirt-gconfig/libvirt-gconfig-domain-filesys.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h index 4f3973e..4144976 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h @@ -75,6 +75,8 @@ typedef enum { GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_PATH, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_HANDLE, +GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_LOOP, +GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD, Can you add GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_PLOOP while at it? (if you don't have libvirt commit rights, I can do that before pushing) I'll do it. I think I have the commit rights, as on the libvirt and libvirt-sandbox repos. -- Cedric -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 2/3] util: virDirCreate: Child now exits with positive errno-code
Previous patch of this series proposed a fix to virDirCreate, so that parent process reports an error if child process failed its task. However our logic still permits the child to exit with negative errno followed by a check of the status on the parent side using WEXITSTATUS which, being POSIX compliant, takes the lower 8 bits of the exit code and returns is to the caller. However, by taking 8 bits from a negative exit code (two's complement) the status value we read and append to stream is '2^8 - abs(original exit code)' which doesn't quite reflect the real cause when compared to the meaning of errno values. --- src/util/virfile.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 5e678fe..91e460f 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2413,12 +2413,12 @@ virDirCreate(const char *path, /* set desired uid/gid, then attempt to create the directory */ if (virSetUIDGID(uid, gid, groups, ngroups) 0) { -ret = -errno; +ret = errno; goto childerror; } if (mkdir(path, mode) 0) { -ret = -errno; -if (ret != -EACCES) { +ret = errno; +if (ret != EACCES) { /* in case of EACCES, the parent will retry */ virReportSystemError(errno, _(child failed to create directory '%s'), path); @@ -2428,13 +2428,13 @@ virDirCreate(const char *path, /* check if group was set properly by creating after * setgid. If not, try doing it with chown */ if (stat(path, st) == -1) { -ret = -errno; +ret = errno; virReportSystemError(errno, _(stat of '%s' failed), path); goto childerror; } if ((st.st_gid != gid) (chown(path, (uid_t) -1, gid) 0)) { -ret = -errno; +ret = errno; virReportSystemError(errno, _(cannot chown '%s' to group %u), path, (unsigned int) gid); @@ -2447,6 +2447,10 @@ virDirCreate(const char *path, goto childerror; } childerror: +if ((ret 0xff) != ret) { +VIR_WARN(unable to pass desired return value %d, ret); +ret = 0xff; +} _exit(ret); } -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 0/3] Fix and tweak 'uknown cause' error in virDirCreate
Erik Skultety (3): util: virfile: Fix 'unknown cause' error if NFS mount point creation fails util: virDirCreate: Child now exits with positive errno-code virfile: virDirCreate: Insert blank lines to assure slightly better readability src/util/virfile.c | 44 +++- 1 file changed, 35 insertions(+), 9 deletions(-) -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 3/3] virfile: virDirCreate: Insert blank lines to assure slightly better readability
--- This could easily be pushed under trivial rule, right? src/util/virfile.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/util/virfile.c b/src/util/virfile.c index 91e460f..61f6e4d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2376,6 +2376,7 @@ virDirCreate(const char *path, if (pid) { /* parent */ /* wait for child to complete, and retrieve its exit code */ VIR_FREE(groups); + while ((waitret = waitpid(pid, status, 0)) == -1 errno == EINTR); if (waitret == -1) { ret = -errno; @@ -2416,6 +2417,7 @@ virDirCreate(const char *path, ret = errno; goto childerror; } + if (mkdir(path, mode) 0) { ret = errno; if (ret != EACCES) { @@ -2425,6 +2427,7 @@ virDirCreate(const char *path, } goto childerror; } + /* check if group was set properly by creating after * setgid. If not, try doing it with chown */ if (stat(path, st) == -1) { @@ -2433,6 +2436,7 @@ virDirCreate(const char *path, _(stat of '%s' failed), path); goto childerror; } + if ((st.st_gid != gid) (chown(path, (uid_t) -1, gid) 0)) { ret = errno; virReportSystemError(errno, @@ -2440,12 +2444,14 @@ virDirCreate(const char *path, path, (unsigned int) gid); goto childerror; } + if (mode != (mode_t) -1 chmod(path, mode) 0) { virReportSystemError(errno, _(cannot set mode of '%s' to %04o), path, mode); goto childerror; } + childerror: if ((ret 0xff) != ret) { VIR_WARN(unable to pass desired return value %d, ret); -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [glib v2 0/4] Filesystem config improvements
Hey, Thanks for adding the test! ACK to patches 1, 3 and 4, one comment in 2. Christophe On Tue, Jun 16, 2015 at 10:58:10AM +0200, Cédric Bosdonnat wrote: Hi all, Here is the previous patch split into a series. The difference with v1 are: * it adds test-gconfig test for file systems * the gvir_config_domain_filesys_set_driver_type fix has been moved to its own commit * the gvir_config_domain_filesys_set_driver_format doesn't set the type, the user just has to make sure he doesn't do stupid things * a test for the new function has been added to test-gconfig Cédric Bosdonnat (4): test-gconfig: add filesystem test gvir_config_domain_filesys_set_driver_type: replace the driver node Add loop and nbd filesystem types domain config: add API to set the filesystem image format libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 18 +++- libvirt-gconfig/libvirt-gconfig-domain-filesys.h | 4 +++ libvirt-gconfig/libvirt-gconfig.sym | 5 tests/test-gconfig.c | 36 tests/xml/gconfig-domain-device-filesys.xml | 15 ++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/xml/gconfig-domain-device-filesys.xml -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list pgp3Z7V7Tvvuu.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] netserver: Remove duplicate forward declaration
Commit fa14207368820b264123ba8429927b62258f996e added forward declaration of virNetServerPtr into virnetserver.h even though we are keeping these in virnetserverprogram.h due to older compilers having problems with duplicate ones. Signed-off-by: Martin Kletzander mklet...@redhat.com --- Pushed as a build-breaker src/rpc/virnetserver.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h index 5c28182ffd15..0e16e8fb1bf0 100644 --- a/src/rpc/virnetserver.h +++ b/src/rpc/virnetserver.h @@ -33,8 +33,6 @@ # include virobject.h # include virjson.h -typedef struct _virNetServer virNetServer; -typedef virNetServer *virNetServerPtr; virNetServerPtr virNetServerNew(size_t min_workers, size_t max_workers, -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] network: add an option to make dns public
On 06/16/2015 09:08 AM, Cedric Bosdonnat wrote: Hi Laine, On Thu, 2015-06-11 at 13:37 -0400, Laine Stump wrote: On 06/10/2015 03:56 PM, John Ferlan wrote: On 06/01/2015 07:54 AM, Cédric Bosdonnat wrote: In some use cases we don't want the virtual network's DNS to only listen to the vnet interface. Adding a publiclyAccessible attribute :-) Really, that name was only intended as a placeholder! I was hoping you (or someone else) would be able to find something shorter/simpler. Lacking that, I guess this is a reasonable name though. Given the other names around that didn't shock me, but it's surely not a good habit to introduce such lengthy names ;) Well, forwardPlainNames was another invention of mine, and one which I'm not proud of, but I gave fair published notice that I would accept other suggestions, and still couldn't come up with something better. The trick is in getting the balance between short/cryptic and long/unambiguously descriptive right. The worst outcome is to have something short and cryptic that could easily be misunderstood to mean something else. Do you think public is specific enough? Or might that possibly be confused with some other intent? to the dns element in the configuration allows the DNS to listen to all interfaces. It simply disables the bind-dynamic option of dnsmasq for the network. --- docs/formatnetwork.html.in | 11 +++ docs/schemas/network.rng | 15 ++- src/conf/network_conf.c | 6 ++ src/conf/network_conf.h | 1 + src/network/bridge_driver.c | 4 +++- tests/networkxml2confdata/nat-network-dns-hosts.conf | 1 - tests/networkxml2confdata/nat-network-dns-hosts.xml | 2 +- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in index 6abed8f..8e43658 100644 --- a/docs/formatnetwork.html.in +++ b/docs/formatnetwork.html.in @@ -851,6 +851,17 @@ DNS server. /p +p + The dns element + can have an optional codepubliclyAccessible/code + attribute span class=sinceSince 1.2.17/span. + If codepubliclyAccessible/code is yes, then the DNS server + will handle requests for all interfaces. + If codepubliclyAccessible/code is not set or no, the DNS + server will only handle requests for the interface of the virtual + network. +/p + Currently supported sub-elements of codelt;dnsgt;/code are: dl dtcodeforwarder/code/dt diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index 4edb6eb..f989625 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -244,12 +244,17 @@ and other features in the dns element -- optional element name=dns -optional - attribute name=forwardPlainNames -ref name=virYesNo/ - /attribute -/optional interleave + optional +attribute name=forwardPlainNames + ref name=virYesNo/ +/attribute + /optional + optional +attribute name=publiclyAccessible + ref name=virYesNo/ +/attribute + /optional Moving the attributes inside the interleave had me looking through other .rng's... I'm no expert, but had thought they really only mattered for element's I'm not an expert either, but you are correct :-) I'm fixing that one. zeroOrMore element name=forwarder attribute name=addrref name=ipAddr//attribute diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index f4a9df0..99bac6d 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1309,9 +1309,14 @@ virNetworkDNSDefParseXML(const char *networkName, size_t i; int ret = -1; xmlNodePtr save = ctxt-node; +char *publiclyAccessible = NULL; ctxt-node = node; +publiclyAccessible = virXPathString(string(./@publiclyAccessible), ctxt); +if (publiclyAccessible) +def-publiclyAccessible = virTristateBoolTypeFromString(publiclyAccessible); + forwardPlainNames = virXPathString(string(./@forwardPlainNames), ctxt); if (forwardPlainNames) { def-forwardPlainNames = virTristateBoolTypeFromString(forwardPlainNames); @@ -1410,6 +1415,7 @@ virNetworkDNSDefParseXML(const char *networkName, ret = 0; cleanup: +VIR_FREE(publiclyAccessible); VIR_FREE(forwardPlainNames); VIR_FREE(fwdNodes); VIR_FREE(hostNodes); diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index f69d999..f555b6b 100644 --- a/src/conf/network_conf.h
Re: [libvirt] [PATCH sandbox 3/3] Add LIBVIRT_SANDBOX_INIT_DEBUG env variable
On Tue, 2015-06-16 at 12:25 +0100, Daniel P. Berrange wrote: Allow debugging of the init process separately from debugging of libvirt sandbox infrastructure, by using the new env var LIBVIRT_SANDBOX_INIT_DEBUG=1. --- libvirt-sandbox/libvirt-sandbox-builder-container.c | 3 +-- libvirt-sandbox/libvirt-sandbox-builder-machine.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c b/libvirt-sandbox/libvirt-sandbox-builder-container.c index c3a58b2..8db69de 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-container.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c @@ -125,8 +125,7 @@ static gchar *gvir_sandbox_builder_container_cmdline(GVirSandboxConfig *config G gchar *tmp; /* Now kernel args */ -if (getenv(LIBVIRT_SANDBOX_DEBUG) -g_str_equal(getenv(LIBVIRT_SANDBOX_DEBUG), 2)) +if (getenv(LIBVIRT_SANDBOX_INIT_DEBUG)) g_string_append(str, debug); if ((tmp = getenv(LIBVIRT_SANDBOX_STRACE))) { diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c index e342ba1..c04dee9 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c @@ -232,8 +232,7 @@ static gchar *gvir_sandbox_builder_machine_cmdline(GVirSandboxConfig *config G_G /* Now kernel args */ g_string_append(str, console=ttyS0); -if (getenv(LIBVIRT_SANDBOX_DEBUG) -g_str_equal(getenv(LIBVIRT_SANDBOX_DEBUG), 2)) +if (getenv(LIBVIRT_SANDBOX_INIT_DEBUG)) g_string_append(str, debug loglevel=10 earlyprintk=ttyS0); else g_string_append(str, quiet loglevel=0); ACK -- Cedric -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 8/9] qemu: migration: selective block device migration
On 16.06.2015 00:42, Pavel Boldin wrote: Implement a `migrate_disks' parameters for the QEMU driver. This multi- value parameter can be used to explicitly specify what block devices are to be migrated using the NBD server. Tunnelled migration using NBD is to be done. Signed-off-by: Pavel Boldin pbol...@mirantis.com Signed-off-by: Michal Privoznik mpriv...@redhat.com --- include/libvirt/libvirt-domain.h | 9 ++ src/qemu/qemu_driver.c | 78 ++--- src/qemu/qemu_migration.c| 245 --- src/qemu/qemu_migration.h| 24 ++-- 4 files changed, 264 insertions(+), 92 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index d851225..7564c20 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -748,6 +748,15 @@ typedef enum { */ # define VIR_MIGRATE_PARAM_LISTEN_ADDRESSlisten_address +/** + * VIR_MIGRATE_PARAM_MIGRATE_DISKS: + * + * virDomainMigrate* params multiple field: The multiple values that list + * the block devices to be migrated. At the moment this is only supported + * by the QEMU driver but not for the tunnelled migration. + */ +# define VIR_MIGRATE_PARAM_MIGRATE_DISKSmigrate_disks + /* Domain migration. */ virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn, unsigned long flags, const char *dname, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 34e5581..c244f46 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12226,7 +12226,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, ret = qemuMigrationPrepareDirect(driver, dconn, NULL, 0, NULL, NULL, /* No cookies */ uri_in, uri_out, - def, origname, NULL, flags); + def, origname, NULL, 0, NULL, flags); cleanup: VIR_FREE(origname); @@ -12279,7 +12279,7 @@ qemuDomainMigratePerform(virDomainPtr dom, * Consume any cookie we were able to decode though */ ret = qemuMigrationPerform(driver, dom-conn, vm, - NULL, dconnuri, uri, NULL, NULL, + NULL, dconnuri, uri, NULL, NULL, 0, NULL, cookie, cookielen, NULL, NULL, /* No output cookies in v2 */ flags, dname, resource, false); @@ -12356,7 +12356,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain, } return qemuMigrationBegin(domain-conn, vm, xmlin, dname, - cookieout, cookieoutlen, flags); + cookieout, cookieoutlen, flags, 0, NULL); } static char * @@ -12369,11 +12369,14 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, { const char *xmlin = NULL; const char *dname = NULL; +const char **migrate_disks = NULL; +int nmigrate_disks; +char *ret = NULL; virDomainObjPtr vm; virCheckFlags(QEMU_MIGRATION_FLAGS, NULL); if (virTypedParamsValidate(params, nparams, QEMU_MIGRATION_PARAMETERS) 0) -return NULL; +goto cleanup; if (virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_DEST_XML, @@ -12381,18 +12384,30 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_DEST_NAME, dname) 0) -return NULL; +goto cleanup; + +nmigrate_disks = virTypedParamsGetAllStrings( +params, nparams, VIR_MIGRATE_PARAM_MIGRATE_DISKS, +migrate_disks); This is formated suspiciously. + +if (nmigrate_disks 0) +goto cleanup; if (!(vm = qemuDomObjFromDomain(domain))) -return NULL; +goto cleanup; if (virDomainMigrateBegin3ParamsEnsureACL(domain-conn, vm-def) 0) { virDomainObjEndAPI(vm); -return NULL; +goto cleanup; } -return qemuMigrationBegin(domain-conn, vm, xmlin, dname, - cookieout, cookieoutlen, flags); +ret = qemuMigrationBegin(domain-conn, vm, xmlin, dname, + cookieout, cookieoutlen, flags, + nmigrate_disks, migrate_disks); + + cleanup: +VIR_FREE(migrate_disks); +return ret; } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1fa5e5f..69a3e9e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1579,12 +1579,34 @@ qemuMigrationPrecreateDisk(virConnectPtr conn, @@ -2806,7 +2871,9 @@ qemuMigrationBegin(virConnectPtr conn, const char *dname,
Re: [libvirt] [PATCH v4 0/9] Selective block device migration implementation
On 16.06.2015 00:42, Pavel Boldin wrote: Behold of the fourth re-roll of the selective block device migration patch. In this patch we don't only fix the issue with NBD migration format auto- detection but also introduce the patches that do enhance the NBD migration triggered by `drive-mirror` QEMU command with ability for the user to select what disks are to be migrated based on the target name. First two patches fix some nitpicks, third one fixes the issue with NBD format auto-detection. Middle ones introduce a necessary API to keep a list of block devices to migrate in the virTypedParameter array and to work with this list. Of the two last patches first introduces the `migrate_disks' qemuMigration* parameter and pushes it down the call stack making the code to consult it when there is a decision to be made whether the block device is to be migrated to the new host. When there is no `migrate_disks' parameter given then the old scheme is used: only non-shared non-readonly disks with a source are migrated. The last patch promotes this ability up to the virsh utility and documents it as appropriate. Michal Privoznik (3): virDomainDiskGetSource: Mark passed disk as 'const' qemuMigrationBeginPhase: Fix function header indentation qemuMigrationDriveMirror: Force raw format for NBD Pavel Boldin (6): util: multi-value virTypedParameter util: multi-value parameters in virTypedParamsAdd* util: virTypedParams{Filter,GetAllStrings} util: add virTypedParamsAddStringList qemu: migration: selective block device migration virsh: selective block device migration include/libvirt/libvirt-domain.h | 9 ++ include/libvirt/libvirt-host.h | 11 ++ src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/libvirt_public.syms | 6 + src/qemu/qemu_driver.c | 78 --- src/qemu/qemu_migration.c| 264 +-- src/qemu/qemu_migration.h| 24 ++-- src/util/virtypedparam.c | 259 +++--- src/util/virtypedparam.h | 19 +++ tests/Makefile.am| 6 + tests/virtypedparamtest.c| 295 +++ tools/virsh-domain.c | 23 +++ tools/virsh.pod | 21 +-- 14 files changed, 854 insertions(+), 165 deletions(-) create mode 100644 tests/virtypedparamtest.c Basically, this is the diff of the all nits I've pointed out: diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f7373af..6c41e89 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2272,6 +2272,8 @@ virTypedParameterTypeFromString; virTypedParameterTypeToString; virTypedParamsCheck; virTypedParamsCopy; +virTypedParamsFilter; +virTypedParamsGetAllStrings; virTypedParamsReplaceString; virTypedParamsValidate; diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index ccc7532..59d8c12 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -717,7 +717,6 @@ LIBVIRT_1.2.16 { LIBVIRT_1.3.0 { global: -virTypedParamsGetAllStrings; virTypedParamsAddStringList; } LIBVIRT_1.2.16; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d56579b..4c6b530 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12351,7 +12351,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain, } return qemuMigrationBegin(domain-conn, vm, xmlin, dname, - cookieout, cookieoutlen, flags, 0, NULL); + cookieout, cookieoutlen, 0, NULL, flags); } static char * @@ -12381,9 +12381,9 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, dname) 0) goto cleanup; -nmigrate_disks = virTypedParamsGetAllStrings( -params, nparams, VIR_MIGRATE_PARAM_MIGRATE_DISKS, -migrate_disks); +nmigrate_disks = virTypedParamsGetAllStrings(params, nparams, + VIR_MIGRATE_PARAM_MIGRATE_DISKS, + migrate_disks); if (nmigrate_disks 0) goto cleanup; @@ -12397,8 +12397,8 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, } ret = qemuMigrationBegin(domain-conn, vm, xmlin, dname, - cookieout, cookieoutlen, flags, - nmigrate_disks, migrate_disks); + cookieout, cookieoutlen, + nmigrate_disks, migrate_disks, flags); cleanup: VIR_FREE(migrate_disks); @@ -12495,9 +12495,9 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, listenAddress) 0) goto cleanup; -nmigrate_disks = virTypedParamsGetAllStrings( -params, nparams, VIR_MIGRATE_PARAM_MIGRATE_DISKS, -
Re: [libvirt] [PATCH v4 4/9] util: multi-value virTypedParameter
On 16.06.2015 00:42, Pavel Boldin wrote: The `virTypedParamsValidate' function now can be instructed to allow multiple entries for some of the keys. For this flag the type with the `VIR_TYPED_PARAM_MULTIPLE' flag. Add unit tests for this new behaviour. Signed-off-by: Pavel Boldin pbol...@mirantis.com Signed-off-by: Michal Privoznik mpriv...@redhat.com --- src/util/virtypedparam.c | 109 +++--- src/util/virtypedparam.h | 10 +++ tests/Makefile.am | 6 ++ tests/virtypedparamtest.c | 167 ++ 4 files changed, 253 insertions(+), 39 deletions(-) create mode 100644 tests/virtypedparamtest.c diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index de2d447..68620f5 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -47,11 +47,19 @@ VIR_ENUM_IMPL(virTypedParameter, VIR_TYPED_PARAM_LAST, * internal utility functions (those in libvirt_private.syms) may * report errors that the caller will dispatch. */ +static int +virTypedParamsSortName(const void *left, const void *right) +{ +const virTypedParameter *param_left = left, *param_right = right; +return strcmp(param_left-field, param_right-field); +} + /* Validate that PARAMS contains only recognized parameter names with - * correct types, and with no duplicates. Pass in as many name/type - * pairs as appropriate, and pass NULL to end the list of accepted - * parameters. Return 0 on success, -1 on failure with error message - * already issued. */ + * correct types, and with no duplicates except for parameters + * specified with VIR_TYPED_PARAM_MULTIPLE flag in type. + * Pass in as many name/type pairs as appropriate, and pass NULL to end + * the list of accepted parameters. Return 0 on success, -1 on failure + * with error message already issued. */ int virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...) { @@ -60,60 +68,83 @@ virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...) size_t i, j; const char *name; int type; +size_t nkeys = 0, nkeysalloc = 0; +virTypedParameterPtr sorted = NULL, keys = NULL; va_start(ap, nparams); -/* Yes, this is quadratic, but since we reject duplicates and - * unknowns, it is constrained by the number of var-args passed - * in, which is expected to be small enough to not be - * noticeable. */ -for (i = 0; i nparams; i++) { -va_end(ap); -va_start(ap, nparams); +if (VIR_ALLOC_N(sorted, nparams) 0) +goto cleanup; -name = va_arg(ap, const char *); -while (name) { -type = va_arg(ap, int); -if (STREQ(params[i].field, name)) { -if (params[i].type != type) { -const char *badtype; - -badtype = virTypedParameterTypeToString(params[i].type); -if (!badtype) -badtype = virTypedParameterTypeToString(0); -virReportError(VIR_ERR_INVALID_ARG, - _(invalid type '%s' for parameter '%s', - expected '%s'), - badtype, params[i].field, - virTypedParameterTypeToString(type)); -} -break; -} -name = va_arg(ap, const char *); -} -if (!name) { -virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, - _(parameter '%s' not supported), - params[i].field); +/* Here we intentionally don't copy values */ +memcpy(sorted, params, sizeof(*params) * nparams); +qsort(sorted, nparams, sizeof(*sorted), virTypedParamsSortName); + +name = va_arg(ap, const char *); +while (name) { +type = va_arg(ap, int); +if (VIR_RESIZE_N(keys, nkeysalloc, nkeys, 1) 0) +goto cleanup; + +if (virStrcpyStatic(keys[nkeys].field, name) == NULL) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _(Field name '%s' too long), name); goto cleanup; } -for (j = 0; j i; j++) { -if (STREQ(params[i].field, params[j].field)) { + +keys[nkeys].type = type ~VIR_TYPED_PARAM_MULTIPLE; +/* Value is not used anyway */ +keys[nkeys].value.i = type VIR_TYPED_PARAM_MULTIPLE; + +nkeys++; +name = va_arg(ap, const char *); +} + +qsort(keys, nkeys, sizeof(*keys), virTypedParamsSortName); + +for (i = 0, j = 0; i nparams j nkeys;) { +if (STRNEQ(sorted[i].field, keys[j].field)) { +j++; +} else { +if (i j !(keys[j].value.i VIR_TYPED_PARAM_MULTIPLE)) { virReportError(VIR_ERR_INVALID_ARG,
Re: [libvirt] nodedev-dumpxml doesn't refresh supported offload NIC capabilities
On 06/16/2015 10:12 AM, Moshe Levi wrote: Hi, I was playing with the nodedev-dumpxml to see the supported offload NIC capabilities, and It seem that if I disable one of offloading capabilities using ethtool command nodedev-dumpxml it still return the feature as enabled. To get the correct offloading capabilities I have to restart libvirtd. I was wandering if that is an expected behavior in lbivirt . the nodedevice driver caches all the information it gets from udev, and tries to rely on udev generating events when something changes. In general this is a bad idea, and has led to at least 2 bug reports I can think of. The function update_caps() in the nodedev driver is intended to be filled in with code to update those attributes of a device that don't get properly updated via udev event responses. It looks like all that would be required in your situation would be to add a call to virNetDevGetFeatures() to the VIR_NODE_DEV_CAP_NET case of the switch in that function. It's complicated a bit by the fact that virNetDevGetFeatures() leaks any existing bitmap of features when it's called. I'm sending a short patch that should fix your problem, which should show up on the list in a few minutes. Please see example below with the rx capabilities disabled. virsh # nodedev-dumpxml net_enp4s0_f4_52_14_11_73_81 device namenet_enp4s0_f4_52_14_11_73_81/name path/sys/devices/pci:00/:00:02.0/:04:00.0/net/enp4s0/path parentpci__04_00_0/parent capability type='net' interfaceenp4s0/interface addressf4:52:14:11:73:81/address link speed='4' state='up'/ feature name='rx'/ feature name='tx'/ feature name='sg'/ feature name='tso'/ feature name='gso'/ feature name='gro'/ feature name='rxvlan'/ feature name='txvlan'/ feature name='rxhash'/ capability type='80203'/ /capability /device ethtool -K enp4s0 rx off virsh # nodedev-dumpxml net_enp4s0_f4_52_14_11_73_81 device namenet_enp4s0_f4_52_14_11_73_81/name path/sys/devices/pci:00/:00:02.0/:04:00.0/net/enp4s0/path parentpci__04_00_0/parent capability type='net' interfaceenp4s0/interface addressf4:52:14:11:73:81/address link speed='4' state='up'/ feature name='rx'/ feature name='tx'/ feature name='sg'/ feature name='tso'/ feature name='gso'/ feature name='gro'/ feature name='rxvlan'/ feature name='txvlan'/ feature name='rxhash'/ capability type='80203'/ /capability /device virsh # [root@r-ae-host05 bin]# ps -ef | grep libvirt root 16743 23086 0 16:43 pts/200:00:00 ../sbin/libvirtd root 17440 23086 0 16:47 pts/200:00:00 grep --color=auto libvirt [root@r-ae-host05 bin]# kill 16743 [root@r-ae-host05 bin]# ../sbin/libvirtd [2] 17489 [1] Done../sbin/libvirtd [root@r-ae-host05 bin]# [root@r-ae-host05 bin]# [root@r-ae-host05 bin]# ./virsh virsh # nodedev-dumpxml net_enp4s0_f4_52_14_11_73_81 device namenet_enp4s0_f4_52_14_11_73_81/name path/sys/devices/pci:00/:00:02.0/:04:00.0/net/enp4s0/path parentpci__04_00_0/parent capability
[libvirt] Continuation of Admin APIs
So now that we have the Admin API backend merged in, the code is prepared to have new APIs added in. There are many things to be added, but we should start out slowly with the most desired ones. I'll try to outline what I have in my mind so the discussion can sprout into existence. As Erik (Cc'd) expressed his interest in this, I'm just summarizing my ideas here, feel free to trash them if you feel like your idea is better. Apart from adding new APIs, we also need to split virsh to create virt-admin. I've hit a few bumps on that and Erik started looking at that either, but that's outside of the scope of this email. * What to start with ** Changing debugging settings This is something that makes sense and should be easy to do. I imagine something along the lines of virAdmSetDebug() being able to setup log_level, log_filters, log_outputs (and maybe log_buffer_size). The question is whether we want these to be three (or four) parameters (since that number in unlikely to change) or typed parameters. Even though I like the extensibility of typed parameters, I'd probably vote for the former. Mainly because this might become syntactic sugar to some heavier API (see below). There might be flags for persisting such settings, but that's highly debatable and might be also done later on. The only situation in which we might not want this API is if there is another one that is able to stream debug logs using virStream. There must be some double-buffering done for this since we would ran into bunch of problems. ** Reporting connection/client information This is a harder one to design since there is not primary key associated with each client. We'll need to come up with some, maybe combined one (based on more information, e.g. socket info, connection time). And if there's nothing better, then I guess associating a ID with each new connection (be it uint64 or UUID) will have to do. Then we have to come up with how to represent the client data so it's scalable. We might need to resort to something else than a structure, for binary extensibility. ** Forcibly disconnecting a client I haven't checked this thoroughly, but I can certainly see the problem where setting client-wantClose = true might just not be enough. If all non-workers are occupied with blocking API, disconnecting clients won't help with making the server accessible again. And that leads me to another one. ** Changing worker pool parameters In case the (maximum) number of workers needs to be changed, it should be possible by this API. However, there's yet again a question whether this is needed if we'll have a bigger gun for all daemon settings. That's described in the next section. * Future ideas (for consideration) ** Changing any settings for the libvirt daemon. I had an idea that we should have a universal API for changing any settings that comes from config files. The API that would implement this would have a string parameter (or list of strings) that would say what setting(s) to change, similarly to augtool. So let's say instead of: $ augtool -s set /files/etc/libvirt/libvirtd.conf/max_workers 10 one would call: virAdmSetConfig(libvirtd.conf/max_workers, 10, ...); Good thing about this is that it is highly scalable (even to qemu.conf). Bad thing is that we need to be able to say whether there is a setting that we don't yet support (return error_unsupported) and also we'd need to rework the configuration module to be able to do such thing and have a function to call for each change. Having this would render changing max_workers, log_level etc. obsolete (although I feel like changing debug parameters still deserves its own API function). ** Reloading the server's TLS certificates? This was requested by Lee (Cc'd) in a reply to one of the PoC series. It is something that I feel like we really want as well, but I haven't yet put much thought into it. That's all from me now. I won't have much access to my mail in couple of following days, so I'll be slower to respond, even slower than my usual slow. Have a nice day, Martin signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] ANNOUNCE: libvirt-glib version 0.2.1 released
I am pleased to announce that a new release of the libvirt-glib package, version 0.2.1, is now available from ftp://libvirt.org/libvirt/glib/ The packages are GPG signed with Key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF (4096R) Changes in this release: - Fix libtoolize detection in autogen.sh - Allow storage volume format compatibility level to be set - Add pre-condition checks to more public API entry points - Don't try to return a value from void functions - Add API for controlling storage pool autostart flag - Add API for filesystem image format - Add loop, nbd and ploop filesystem types - Fix setting of driver type when called more than once libvirt-glib comprises three distinct libraries: - libvirt-glib- Integrate with the GLib event loop and error handling - libvirt-gconfig - Representation of libvirt XML documents as GObjects - libvirt-gobject - Mapping of libvirt APIs into the GObject type system NB: While libvirt aims to be API/ABI stable forever, with libvirt-glib we are not currently guaranteeing that libvirt-glib libraries are permanently API/ABI stable. That said we do not expect to break the API/ABI for the forseeable future and will always strive avoid it. Follow up comments about libvirt-glib should be directed to the regular libvir-list@redhat.com development list. Thanks to all the people involved in contributing to this release. Regards, 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 v4 6/9] util: virTypedParams{Filter, GetAllStrings}
On 16.06.2015 00:42, Pavel Boldin wrote: Add multikey API: * virTypedParamsFilter that filters all the parameters with specified name. * virTypedParamsGetAllStrings that returns a list with all the values for specified name and string type. Signed-off-by: Pavel Boldin pbol...@mirantis.com Signed-off-by: Michal Privoznik mpriv...@redhat.com --- include/libvirt/libvirt-host.h | 5 ++ src/libvirt_public.syms| 5 ++ src/util/virtypedparam.c | 102 + src/util/virtypedparam.h | 9 tests/Makefile.am | 2 +- tests/virtypedparamtest.c | 100 6 files changed, 222 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 070550b..8222cfb 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -284,6 +284,11 @@ virTypedParamsGetString (virTypedParameterPtr params, const char *name, const char **value); int +virTypedParamsGetAllStrings(virTypedParameterPtr params, + int nparams, + const char *name, + const char ***values); +int virTypedParamsAddInt(virTypedParameterPtr *params, int *nparams, int *maxparams, diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 716dd2f..0a1feea 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -715,4 +715,9 @@ LIBVIRT_1.2.16 { virDomainSetUserPassword; } LIBVIRT_1.2.15; +LIBVIRT_1.3.0 { +global: +virTypedParamsGetAllStrings; +} LIBVIRT_1.2.16; + I don't think this symbol needs to be exported. # define new API here using predicted next version number diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 6f608d6..a12006c 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -482,6 +482,51 @@ virTypedParamsGet(virTypedParameterPtr params, } +/** + * virTypedParamsFilter: + * @params: array of typed parameters + * @nparams: number of parameters in the @params array + * @name: name of the parameter to find + * @ret: pointer to the returned array + * + * Filters @params retaining only the parameters named @name in the + * resulting array @ret. Caller should free the @ret array but not + * the items since they are pointing to the @params elements. + * + * Returns amount of elements in @ret on success, -1 on error. + */ +int +virTypedParamsFilter(virTypedParameterPtr params, + int nparams, + const char *name, + virTypedParameterPtr **ret) +{ +size_t i, alloc = 0, n = 0; + +virCheckNonNullArgGoto(params, error); +virCheckNonNullArgGoto(name, error); +virCheckNonNullArgGoto(ret, error); + +*ret = NULL; + +for (i = 0; i nparams; i++) { +if (STREQ(params[i].field, name)) { +if (VIR_RESIZE_N(*ret, alloc, n, 1) 0) +goto error; + +(*ret)[n] = params[i]; + +n++; +} +} + +return n; + + error: +return -1; +} + + #define VIR_TYPED_PARAM_CHECK_TYPE(check_type) \ do { if (param-type != check_type) { \ virReportError(VIR_ERR_INVALID_ARG, \ @@ -750,6 +795,63 @@ virTypedParamsGetString(virTypedParameterPtr params, /** + * virTypedParamsGetAllStrings: + * @params: array of typed parameters + * @nparams: number of parameters in the @params array + * @name: name of the parameter to find + * @values: array of returned values + * + * Finds all parameters with desired @name within @params and + * store their values into @values. The @values array is self + * allocated and its length is stored into @picked. When no + * longer needed, caller should free the returned array, but not + * the items since they are taken from @params array. + * + * Returns amount of strings in @values array on success, + * -1 otherwise. + */ +int +virTypedParamsGetAllStrings(virTypedParameterPtr params, +int nparams, +const char *name, +const char ***values) +{ +size_t i, n; +int nfiltered; +virTypedParameterPtr *filtered = NULL; + +virResetLastError(); + +virCheckNonNullArgGoto(values, error); +*values = NULL; + +nfiltered = virTypedParamsFilter(params, nparams, name, filtered); + +if (nfiltered 0) +goto error; + +if (nfiltered +VIR_ALLOC_N(*values, nfiltered) 0) +goto error; + +for (n = 0, i = 0; i nfiltered; i++) { +if (filtered[i]-type ==
Re: [libvirt] [PATCH sandbox 1/3] Support lzma and gzip compressed kernel modules
On Tue, 2015-06-16 at 12:25 +0100, Daniel P. Berrange wrote: Modern distros like Fedora have started to compress their kernel module files, so we can't simply read the file contents and load the module. We have to first do a decompression step, as the kernel won't do that itself. While Fedora uses lzma, upstream kernels are also capable of using gzip. This links in the lzma and gzip libraries to handle decompression. NB the static versions of lzma/gzip are required since libvirt-sandbox-init-qemu must be statically linked. --- configure.ac | 4 + libvirt-sandbox.spec.in | 2 + libvirt-sandbox/Makefile.am | 7 ++ libvirt-sandbox/libvirt-sandbox-builder-initrd.c | 35 +++--- libvirt-sandbox/libvirt-sandbox-init-qemu.c | 143 ++- 5 files changed, 173 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index cd3745a..4f53c94 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,8 @@ LIBVIRT_GCONFIG_REQUIRED=0.1.8 LIBVIRT_GLIB_REQUIRED=0.1.7 LIBVIRT_GOBJECT_REQUIRED=0.1.7 GOBJECT_INTROSPECTION_REQUIRED=0.10.8 +LZMA_REQUIRED=5.0.0 +ZLIB_REQUIRED=1.2.0 LIBVIRT_SANDBOX_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'` LIBVIRT_SANDBOX_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'` @@ -78,6 +80,8 @@ PKG_CHECK_MODULES(LIBVIRT, libvirt = $LIBVIRT_REQUIRED) PKG_CHECK_MODULES(LIBVIRT_GLIB, libvirt-glib-1.0 = $LIBVIRT_GOBJECT_REQUIRED) PKG_CHECK_MODULES(LIBVIRT_GOBJECT, libvirt-gobject-1.0 = $LIBVIRT_GOBJECT_REQUIRED) PKG_CHECK_MODULES(LIBVIRT_GCONFIG, libvirt-gconfig-1.0 = $LIBVIRT_GCONFIG_REQUIRED) +PKG_CHECK_MODULES(ZLIB, zlib = $ZLIB_REQUIRED) +PKG_CHECK_MODULES(LZMA, liblzma = $LZMA_REQUIRED) Would be great to have some check for the presence of the static libs we need here. rkeene pointed to this example doing similar thing: http://kitcreator.rkeene.org/fossil/info/b344f06840acf86cbd6b6fdc1bd45dd649db9ad2?ln=113-154 Even if not in this commit, would be good to have later. ACK for the rest. -- Cedric LIBVIRT_SANDBOX_CAPNG LIBVIRT_SANDBOX_GETTEXT diff --git a/libvirt-sandbox.spec.in b/libvirt-sandbox.spec.in index 7deadb2..1ec6e27 100644 --- a/libvirt-sandbox.spec.in +++ b/libvirt-sandbox.spec.in @@ -27,6 +27,8 @@ BuildRequires: /usr/bin/pod2man BuildRequires: intltool BuildRequires: libselinux-devel BuildRequires: glib2-devel = 2.32.0 +BuildRequires: xz-devel = 5.0.0, xz-static +BuildRequires: zlib-devel = 1.2.0, zlib-static Requires: rpm-python # For virsh lxc-enter-namespace command Requires: libvirt-client = %{libvirt_version} diff --git a/libvirt-sandbox/Makefile.am b/libvirt-sandbox/Makefile.am index 96302cb..30c9ebf 100644 --- a/libvirt-sandbox/Makefile.am +++ b/libvirt-sandbox/Makefile.am @@ -139,6 +139,7 @@ libvirt_sandbox_1_0_la_CFLAGS = \ -DLOCALEDIR=\$(datadir)/locale\ \ $(COVERAGE_CFLAGS) \ -I$(top_srcdir) \ + -I$(top_builddir) \ $(GIO_UNIX_CFLAGS) \ $(LIBVIRT_GLIB_CFLAGS) \ $(LIBVIRT_GOBJECT_CFLAGS) \ @@ -172,6 +173,7 @@ libvirt_sandbox_init_common_CFLAGS = \ -DLOCALEDIR=\$(datadir)/locale\ \ $(COVERAGE_CFLAGS) \ -I$(top_srcdir) \ + -I$(top_builddir) \ $(GIO_UNIX_CFLAGS) \ $(LIBVIRT_GLIB_CFLAGS) \ $(LIBVIRT_GOBJECT_CFLAGS) \ @@ -196,6 +198,7 @@ libvirt_sandbox_init_lxc_CFLAGS = \ -DLIBEXECDIR=\$(libexecdir)\ \ -DSANDBOXCONFIGDIR=\$(sandboxconfigdir)\ \ -I$(top_srcdir) \ + -I$(top_builddir) \ $(GIO_UNIX_CFLAGS) \ $(LIBVIRT_GLIB_CFLAGS) \ $(LIBVIRT_GOBJECT_CFLAGS) \ @@ -217,11 +220,15 @@ libvirt_sandbox_init_qemu_SOURCES = libvirt-sandbox-init-qemu.c libvirt_sandbox_init_qemu_CFLAGS = \ -DLIBEXECDIR=\$(libexecdir)\ \ -DSANDBOXCONFIGDIR=\$(sandboxconfigdir)\ \ + $(ZLIB_CFLAGS) \ + $(LZMA_CFLAGS) \ $(WARN_CFLAGS) \ $(NULL) libvirt_sandbox_init_qemu_LDFLAGS = \ -all-static \ $(COVERAGE_CFLAGS:-f%=-Wc,f%) \ + $(ZLIB_LIBS) \ + $(LZMA_LIBS) \ $(WARN_CFLAGS) \ $(NULL) diff --git a/libvirt-sandbox/libvirt-sandbox-builder-initrd.c b/libvirt-sandbox/libvirt-sandbox-builder-initrd.c index 95f05e2..59a03e6 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-initrd.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-initrd.c @@ -232,7
Re: [libvirt] [PATCH sandbox 2/3] Explicitly check for supported URIs when starting guests
On Tue, 2015-06-16 at 12:25 +0100, Daniel P. Berrange wrote: While the sandbox API is designed to be hypervisor agnostic, the internal implementation needs work for each hypervisor target. To avoid user errors at runtime, do an upfront check to see if the URI they supply is suitable. Since we don't support remote executions, we do a straight string comparison on the URI, instead of just a protocol check --- .../libvirt-sandbox-context-interactive.c | 27 ++ po/POTFILES.in | 1 + 2 files changed, 28 insertions(+) diff --git a/libvirt-sandbox/libvirt-sandbox-context-interactive.c b/libvirt-sandbox/libvirt-sandbox-context-interactive.c index 78b2fbd..3ab63ec 100644 --- a/libvirt-sandbox/libvirt-sandbox-context-interactive.c +++ b/libvirt-sandbox/libvirt-sandbox-context-interactive.c @@ -24,6 +24,8 @@ #include string.h #include errno.h +#include glib/gi18n.h + #include libvirt-sandbox/libvirt-sandbox.h /** @@ -60,6 +62,13 @@ enum { //static gint signals[LAST_SIGNAL]; +#define GVIR_SANDBOX_CONTEXT_INTERACTIVE_ERROR gvir_sandbox_context_interactive_error_quark() + +static GQuark +gvir_sandbox_context_interactive_error_quark(void) +{ +return g_quark_from_static_string(gvir-sandbox-context-interactive); +} static void gvir_sandbox_context_interactive_get_property(GObject *object, guint prop_id, @@ -198,6 +207,7 @@ static gboolean gvir_sandbox_context_interactive_start(GVirSandboxContext *ctxt, gchar *emptydir; gchar *configfile; gboolean ret = FALSE; +const gchar *uri; if (!GVIR_SANDBOX_CONTEXT_CLASS(gvir_sandbox_context_interactive_parent_class)-start(ctxt, error)) return FALSE; @@ -213,6 +223,23 @@ static gboolean gvir_sandbox_context_interactive_start(GVirSandboxContext *ctxt, configfile = g_build_filename(configdir, sandbox.cfg, NULL); emptydir = g_build_filename(configdir, empty, NULL); +uri = gvir_connection_get_uri(connection); + +if (geteuid() == 0) { +if (!g_str_equal(uri, lxc:///) +!g_str_equal(uri, qemu:///system)) { +g_set_error(error, GVIR_SANDBOX_CONTEXT_INTERACTIVE_ERROR, 0, +_(Only 'lxc:///' or 'qemu:///system' URIs supported when running as root)); +goto cleanup; +} +} else { +if (!g_str_equal(uri, qemu:///session)) { +g_set_error(error, GVIR_SANDBOX_CONTEXT_INTERACTIVE_ERROR, 0, +_(Only 'qemu:///session' URIs supported when running as non-root)); +goto cleanup; +} +} + if (!(builder = gvir_sandbox_builder_for_connection(connection, error))) goto cleanup; diff --git a/po/POTFILES.in b/po/POTFILES.in index 653abc5..11bd5e7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -7,5 +7,6 @@ libvirt-sandbox/libvirt-sandbox-console.c libvirt-sandbox/libvirt-sandbox-console-raw.c libvirt-sandbox/libvirt-sandbox-console-rpc.c libvirt-sandbox/libvirt-sandbox-context.c +libvirt-sandbox/libvirt-sandbox-context-interactive.c libvirt-sandbox/libvirt-sandbox-init-common.c libvirt-sandbox/libvirt-sandbox-rpcpacket.c ACK -- Cedric -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Socket files in virt-aa-helper
On 06/16/2015 08:40 AM, Michał Dubiel wrote: Hi all, May I kindly ask someone for some advice on this topic? Regards, Michal On 21 May 2015 at 20:23, Michał Dubiel m...@semihalf.com mailto:m...@semihalf.com wrote: Hi guys, I have got a question. I need to add apparmor support for vhost-user socket files used to communicate with the vhost-user server app. Those ones defined with something like: interface type='vhostuser' mac address='02:ed:f3:5d:de:f3'/ source type='unix' path='/var/run/vrouter/uvh_vif_tapa8396c51-2a' mode='client'/ model type='virtio'/ address type='pci' domain='0x' bus='0x00' slot='0x03' function='0x0'/ /interface I added something like this into get_files() function in virt-aa-helper.c: for (i = 0; i ctl-def-nnets; i++) { if (ctl-def-nets[i] ctl-def-nets[i]-type == VIR_DOMAIN_NET_TYPE_VHOSTUSER ctl-def-nets[i]-data.vhostuser) { virDomainChrSourceDefPtr vhu = ctl-def-nets[i]-data.vhostuser; if (vah_add_file_chardev(buf, vhu-data.nix.path, rw, vhu-type) != 0) goto cleanup; } } However, there is a restriction for the socket file types in valid_path() function: switch (sb.st_mode S_IFMT) { case S_IFSOCK: return 1; break; default: break; } That prevents this from working. May I ask why the socket file types are restricted? Vhost-user uses sockets so if I want to use apparmor virt-aa-helper has to be able to add the line for the socket file into /etc/apparmor.d/libvirt/libvirt-UUID.files. They are restricted only because at the time virt-aa-helper.c was written there wasn't a valid use for them. There were more checks in this part of the code but over the years as more valid types were added to libvirt, they've been removed and now we are left with just this one. Since there is now a valid usecase for S_IFSOCK, it seems this can simply be removed. -- Jamie Strandboge http://www.ubuntu.com/ signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] nodedev: update netdev feature bits before each dumpxml
As with several other attributes of devices (link status, sriov VF list, IOMMU group list), the detdev feature bits aren't automatically updated in the nodedev driver's cache when they change. In order to get a properly up-to-date list when getting the XML of a device, we must reget them in update-caps prior to each dumpxml. Reported-By: Moshe Levi mosh...@mellanox.com --- I dislike needing to put in the virBitmapFree and set the pointer to NULL before re-getting the features, but leaving it out would lead to a leak of the old bitmap, and I'm not sure I want virNetDevGetFeatures() to assume a valid pointer when it starts (it currently assumes the pointer contents is junk, and overwrites it with a newly allocated *virBitmap). src/node_device/node_device_driver.c | 4 1 file changed, 4 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 768db7f..31741b9 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -58,6 +58,10 @@ static int update_caps(virNodeDeviceObjPtr dev) case VIR_NODE_DEV_CAP_NET: if (virNetDevGetLinkInfo(cap-data.net.ifname, cap-data.net.lnk) 0) return -1; +virBitmapFree(cap-data.net.features); +cap-data.net.features = NULL; +if (virNetDevGetFeatures(cap-data.net.ifname, cap-data.net.features) 0) +return -1; break; case VIR_NODE_DEV_CAP_PCI_DEV: if (nodeDeviceSysfsGetPCIRelatedDevCaps(dev-def-sysfs_path, -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] daemon/Makefile: Add forgotten dependency
In latest patches we added Admin API. However, the Makefile in daemon was missing one dependency: admin_server.c is including generated file admin_dispatch.h. However, this dependency was not explicitly marked in the Makefile therefore the build happened to fail on some occasions. Signed-off-by: Michal Privoznik mpriv...@redhat.com --- Pushed under trivial and build-breaker rules. daemon/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 3d45f2a..bb08d9f 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -317,6 +317,7 @@ endif ! WITH_POLKIT remote.c: $(DAEMON_GENERATED) remote.h: $(DAEMON_GENERATED) +admin_server.c: $(DAEMON_GENERATED) LOGROTATE_CONFS = libvirtd.qemu.logrotate libvirtd.lxc.logrotate \ libvirtd.libxl.logrotate libvirtd.uml.logrotate \ -- 2.3.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] network: add an option to make dns public
On Tue, 2015-06-16 at 11:21 -0400, Laine Stump wrote: On 06/16/2015 09:08 AM, Cedric Bosdonnat wrote: Hi Laine, On Thu, 2015-06-11 at 13:37 -0400, Laine Stump wrote: On 06/10/2015 03:56 PM, John Ferlan wrote: On 06/01/2015 07:54 AM, Cédric Bosdonnat wrote: In some use cases we don't want the virtual network's DNS to only listen to the vnet interface. Adding a publiclyAccessible attribute :-) Really, that name was only intended as a placeholder! I was hoping you (or someone else) would be able to find something shorter/simpler. Lacking that, I guess this is a reasonable name though. Given the other names around that didn't shock me, but it's surely not a good habit to introduce such lengthy names ;) Well, forwardPlainNames was another invention of mine, and one which I'm not proud of, but I gave fair published notice that I would accept other suggestions, and still couldn't come up with something better. The trick is in getting the balance between short/cryptic and long/unambiguously descriptive right. The worst outcome is to have something short and cryptic that could easily be misunderstood to mean something else. Do you think public is specific enough? Or might that possibly be confused with some other intent? public could work, I don't think there are much more cases that would fit this case for the DNS. to the dns element in the configuration allows the DNS to listen to all interfaces. It simply disables the bind-dynamic option of dnsmasq for the network. --- docs/formatnetwork.html.in | 11 +++ docs/schemas/network.rng | 15 ++- src/conf/network_conf.c | 6 ++ src/conf/network_conf.h | 1 + src/network/bridge_driver.c | 4 +++- tests/networkxml2confdata/nat-network-dns-hosts.conf | 1 - tests/networkxml2confdata/nat-network-dns-hosts.xml | 2 +- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in index 6abed8f..8e43658 100644 --- a/docs/formatnetwork.html.in +++ b/docs/formatnetwork.html.in @@ -851,6 +851,17 @@ DNS server. /p +p + The dns element + can have an optional codepubliclyAccessible/code + attribute span class=sinceSince 1.2.17/span. + If codepubliclyAccessible/code is yes, then the DNS server + will handle requests for all interfaces. + If codepubliclyAccessible/code is not set or no, the DNS + server will only handle requests for the interface of the virtual + network. +/p + Currently supported sub-elements of codelt;dnsgt;/code are: dl dtcodeforwarder/code/dt diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index 4edb6eb..f989625 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -244,12 +244,17 @@ and other features in the dns element -- optional element name=dns -optional - attribute name=forwardPlainNames -ref name=virYesNo/ - /attribute -/optional interleave + optional +attribute name=forwardPlainNames + ref name=virYesNo/ +/attribute + /optional + optional +attribute name=publiclyAccessible + ref name=virYesNo/ +/attribute + /optional Moving the attributes inside the interleave had me looking through other .rng's... I'm no expert, but had thought they really only mattered for element's I'm not an expert either, but you are correct :-) I'm fixing that one. zeroOrMore element name=forwarder attribute name=addrref name=ipAddr//attribute diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index f4a9df0..99bac6d 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1309,9 +1309,14 @@ virNetworkDNSDefParseXML(const char *networkName, size_t i; int ret = -1; xmlNodePtr save = ctxt-node; +char *publiclyAccessible = NULL; ctxt-node = node; +publiclyAccessible = virXPathString(string(./@publiclyAccessible), ctxt); +if (publiclyAccessible) +def-publiclyAccessible = virTristateBoolTypeFromString(publiclyAccessible); + forwardPlainNames = virXPathString(string(./@forwardPlainNames), ctxt); if (forwardPlainNames) { def-forwardPlainNames = virTristateBoolTypeFromString(forwardPlainNames); @@ -1410,6 +1415,7 @@ virNetworkDNSDefParseXML(const char
Re: [libvirt] [PATCH 0/4] parallels: rename parallels to vz
On 06/10/2015 10:50 AM, Maxim Nestratov wrote: This change is made in the scope of 'Parallel Cloud Server' pruduct renaming to 'Virtuozzo' to prevent future confusion and make things actual. Previously we introduced a new driver name 'vz' as a synonym to 'parallels'. This patch set finalizes major part of renaming process. Though uri 'parallels:///system' and 'parallels' domain type remains valid, we are going to reference the driver and all changes related to it as 'vz' since now. Thanks, I've pushed this series. Maxim Nestratov (4): parallels: change parallels prefixes to vz parallels: substitute parallels with vz in strings parallels: rename all parallels files and driver directory to vz parallels: substitute parallels with vz spec file and Makefile configure.ac | 26 +- libvirt.spec.in| 10 +- mingw-libvirt.spec.in | 6 +- po/POTFILES.in | 12 +- src/Makefile.am| 36 +- src/libvirt.c | 10 +- .../parallels_driver.c = vz/vz_driver.c} | 386 +- .../parallels_driver.h = vz/vz_driver.h} | 4 +- .../parallels_network.c = vz/vz_network.c}| 142 +++ src/{parallels/parallels_sdk.c = vz/vz_sdk.c} | 244 ++-- src/{parallels/parallels_sdk.h = vz/vz_sdk.h} | 22 +- .../parallels_storage.c = vz/vz_storage.c}| 440 ++--- src/{parallels/parallels_utils.c = vz/vz_utils.c} | 32 +- src/{parallels/parallels_utils.h = vz/vz_utils.h} | 54 +-- 14 files changed, 712 insertions(+), 712 deletions(-) rename src/{parallels/parallels_driver.c = vz/vz_driver.c} (73%) rename src/{parallels/parallels_driver.h = vz/vz_driver.h} (90%) rename src/{parallels/parallels_network.c = vz/vz_network.c} (75%) rename src/{parallels/parallels_sdk.c = vz/vz_sdk.c} (93%) rename src/{parallels/parallels_sdk.h = vz/vz_sdk.h} (75%) rename src/{parallels/parallels_storage.c = vz/vz_storage.c} (74%) rename src/{parallels/parallels_utils.c = vz/vz_utils.c} (84%) rename src/{parallels/parallels_utils.h = vz/vz_utils.h} (68%) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 7/8] test: Refactor testDomainSetVcpusFlags
Remove the bogous flag check and refactor the code by using virDomainObjGetDefs instead of virDomainObjGetPersistentDef. --- src/test/test_driver.c | 68 +- 1 file changed, 23 insertions(+), 45 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 59e2031..cfec122 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2509,6 +2509,7 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus, { testConnPtr privconn = domain-conn-privateData; virDomainObjPtr privdom = NULL; +virDomainDefPtr def; virDomainDefPtr persistentDef; int ret = -1, maxvcpus; @@ -2516,72 +2517,49 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus, VIR_DOMAIN_AFFECT_CONFIG | VIR_DOMAIN_VCPU_MAXIMUM, -1); -/* At least one of LIVE or CONFIG must be set. MAXIMUM cannot be - * mixed with LIVE. */ -if ((flags (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG)) == 0 || -(flags (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_LIVE)) == - (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_LIVE)) { -virReportError(VIR_ERR_INVALID_ARG, - _(invalid flag combination: (0x%x)), flags); +if ((maxvcpus = testConnectGetMaxVcpus(domain-conn, NULL)) == -1) return -1; -} -if (!nrCpus || (maxvcpus = testConnectGetMaxVcpus(domain-conn, NULL)) nrCpus) { + +if (nrCpus maxvcpus) { virReportError(VIR_ERR_INVALID_ARG, - _(argument out of range: %d), nrCpus); + _(requested cpu amount exceeds maximum supported amount + (%d %d)), nrCpus, maxvcpus); return -1; } if (!(privdom = testDomObjFromDomain(domain))) return -1; -if (!virDomainObjIsActive(privdom) (flags VIR_DOMAIN_AFFECT_LIVE)) { -virReportError(VIR_ERR_OPERATION_INVALID, - %s, _(cannot hotplug vcpus for an inactive domain)); +if (virDomainObjGetDefs(privdom, flags, def, persistentDef) 0) goto cleanup; -} - -/* We allow more cpus in guest than host, but not more than the - * domain's starting limit. */ -if (!(flags (VIR_DOMAIN_VCPU_MAXIMUM)) -privdom-def-maxvcpus maxvcpus) -maxvcpus = privdom-def-maxvcpus; -if (nrCpus maxvcpus) { +if ((def + def-maxvcpus nrCpus) || +(persistentDef + !(flags VIR_DOMAIN_VCPU_MAXIMUM) + persistentDef-maxvcpus nrCpus)) { virReportError(VIR_ERR_INVALID_ARG, _(requested cpu amount exceeds maximum (%d %d)), nrCpus, maxvcpus); goto cleanup; } -if (!(persistentDef = virDomainObjGetPersistentDef(privconn-caps, - privconn-xmlopt, - privdom))) +if (def +testDomainUpdateVCPUs(privconn, privdom, nrCpus, 0) 0) goto cleanup; -switch (flags) { -case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_AFFECT_CONFIG: -persistentDef-maxvcpus = nrCpus; -if (nrCpus persistentDef-vcpus) -persistentDef-vcpus = nrCpus; -ret = 0; -break; - -case VIR_DOMAIN_AFFECT_CONFIG: -persistentDef-vcpus = nrCpus; -ret = 0; -break; - -case VIR_DOMAIN_AFFECT_LIVE: -ret = testDomainUpdateVCPUs(privconn, privdom, nrCpus, 0); -break; - -case VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG: -ret = testDomainUpdateVCPUs(privconn, privdom, nrCpus, 0); -if (ret == 0) +if (persistentDef) { +if (flags VIR_DOMAIN_VCPU_MAXIMUM) { +persistentDef-maxvcpus = nrCpus; +if (nrCpus persistentDef-vcpus) +persistentDef-vcpus = nrCpus; +} else { persistentDef-vcpus = nrCpus; -break; +} } +ret = 0; + cleanup: virDomainObjEndAPI(privdom); return ret; -- 2.4.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 6/8] lib: setvcpus: Remove bogous flag check
Since VIR_DOMAIN_AFFECT_CURRENT is 0 the flag check does not make sense as masking @flags with 0 will always equal to false. --- src/libvirt-domain.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7e6d749..4d7b88a 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -7267,12 +7267,6 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, VIR_DOMAIN_AFFECT_CONFIG, error); -VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_CURRENT, - VIR_DOMAIN_AFFECT_LIVE, - error); -VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_CURRENT, - VIR_DOMAIN_AFFECT_CONFIG, - error); VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_VCPU_GUEST, VIR_DOMAIN_AFFECT_CONFIG, error); -- 2.4.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/8] test: Switch to reference counting with testDomObjFromDomain
Retrieve domain objects with reference and release them with virDomainObjEndAPI. --- src/test/test_driver.c | 89 -- 1 file changed, 35 insertions(+), 54 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c0ef459..6613ed7 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -484,7 +484,7 @@ testDomObjFromDomain(virDomainPtr domain) char uuidstr[VIR_UUID_STRING_BUFLEN]; testDriverLock(driver); -vm = virDomainObjListFindByUUID(driver-domains, domain-uuid); +vm = virDomainObjListFindByUUIDRef(driver-domains, domain-uuid); if (!vm) { virUUIDFormat(domain-uuid, uuidstr); virReportError(VIR_ERR_NO_DOMAIN, @@ -6262,19 +6262,17 @@ static int testDomainSnapshotNum(virDomainPtr domain, unsigned int flags) { virDomainObjPtr vm = NULL; -int n = -1; +int n; virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS | VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1); if (!(vm = testDomObjFromDomain(domain))) -goto cleanup; +return -1; n = virDomainSnapshotObjListNum(vm-snapshots, NULL, flags); - cleanup: -if (vm) -virObjectUnlock(vm); +virDomainObjEndAPI(vm); return n; } @@ -6285,20 +6283,18 @@ testDomainSnapshotListNames(virDomainPtr domain, unsigned int flags) { virDomainObjPtr vm = NULL; -int n = -1; +int n; virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS | VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1); if (!(vm = testDomObjFromDomain(domain))) -goto cleanup; +return -1; n = virDomainSnapshotObjListGetNames(vm-snapshots, NULL, names, nameslen, flags); - cleanup: -if (vm) -virObjectUnlock(vm); +virDomainObjEndAPI(vm); return n; } @@ -6308,19 +6304,17 @@ testDomainListAllSnapshots(virDomainPtr domain, unsigned int flags) { virDomainObjPtr vm = NULL; -int n = -1; +int n; virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS | VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1); if (!(vm = testDomObjFromDomain(domain))) -goto cleanup; +return -1; n = virDomainListSnapshots(vm-snapshots, NULL, domain, snaps, flags); - cleanup: -if (vm) -virObjectUnlock(vm); +virDomainObjEndAPI(vm); return n; } @@ -6338,7 +6332,7 @@ testDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot, VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1); if (!(vm = testDomObjFromSnapshot(snapshot))) -goto cleanup; +return -1; if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) goto cleanup; @@ -6347,8 +6341,7 @@ testDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot, flags); cleanup: -if (vm) -virObjectUnlock(vm); +virDomainObjEndAPI(vm); return n; } @@ -6364,7 +6357,7 @@ testDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1); if (!(vm = testDomObjFromSnapshot(snapshot))) -goto cleanup; +return -1; if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) goto cleanup; @@ -6372,8 +6365,7 @@ testDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, n = virDomainSnapshotObjListNum(vm-snapshots, snap, flags); cleanup: -if (vm) -virObjectUnlock(vm); +virDomainObjEndAPI(vm); return n; } @@ -6390,7 +6382,7 @@ testDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot, VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1); if (!(vm = testDomObjFromSnapshot(snapshot))) -goto cleanup; +return -1; if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) goto cleanup; @@ -6399,8 +6391,7 @@ testDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot, flags); cleanup: -if (vm) -virObjectUnlock(vm); +virDomainObjEndAPI(vm); return n; } @@ -6416,7 +6407,7 @@ testDomainSnapshotLookupByName(virDomainPtr domain, virCheckFlags(0, NULL); if (!(vm = testDomObjFromDomain(domain))) -goto cleanup; +return NULL; if (!(snap = testSnapObjFromName(vm, name))) goto cleanup; @@ -6424,8 +6415,7 @@ testDomainSnapshotLookupByName(virDomainPtr domain, snapshot = virGetDomainSnapshot(domain, snap-def-name); cleanup: -if (vm) -virObjectUnlock(vm); +virDomainObjEndAPI(vm); return snapshot; } @@ -6434,18 +6424,16 @@ testDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags) { virDomainObjPtr vm; -int ret = -1; +int ret; virCheckFlags(0, -1); if (!(vm = testDomObjFromDomain(domain))) -goto cleanup; +return -1; ret =
[libvirt] [PATCH 0/8] Test driver refactors and fixes
Note that patch 1/8 of this series depends on patch 2/13 of the vCPU pinning and related refactors - Part 1.5 series: http://www.redhat.com/archives/libvir-list/2015-June/msg00678.html Peter Krempa (8): test: Reuse virDomainObjGetOneDef in testDomainGetVcpusFlags test: Switch to reference counting with testDomObjFromDomain test: Refactor test driver domain object retrieval test: Refactor test driver event sending test: group domain APIs together lib: setvcpus: Remove bogous flag check test: Refactor testDomainSetVcpusFlags test: Fix lock ordering in testDomainRevertToSnapshot src/libvirt-domain.c | 6 - src/test/test_driver.c | 941 + 2 files changed, 324 insertions(+), 623 deletions(-) -- 2.4.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/8] test: Reuse virDomainObjGetOneDef in testDomainGetVcpusFlags
The test driver copies the domain definition correctly so we can reuse the helper. --- src/test/test_driver.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d1f0af3..c0ef459 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2576,13 +2576,9 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) goto cleanup; } -if (virDomainLiveConfigHelperMethod(privconn-caps, privconn-xmlopt, -vm, flags, def) 0) +if (!(def = virDomainObjGetOneDef(vm, flags))) goto cleanup; -if (flags VIR_DOMAIN_AFFECT_LIVE) -def = vm-def; - ret = (flags VIR_DOMAIN_VCPU_MAXIMUM) ? def-maxvcpus : def-vcpus; cleanup: -- 2.4.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 8/8] test: Fix lock ordering in testDomainRevertToSnapshot
The test driver lock should not be acquired while a domain object lock is held. Tweak the lock ordering to avoid possible deadlock. --- src/test/test_driver.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index cfec122..9e617a2 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6603,13 +6603,13 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, * and use of FORCE can cause multiple transitions. */ -if (!(vm = testDomObjFromSnapshot(snapshot))) -return -1; +testDriverLock(privconn); -if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) +if (!(vm = testDomObjFromDomainLocked(privconn, snapshot-domain))) goto cleanup; -testDriverLock(privconn); +if (!(snap = testSnapObjFromSnapshot(vm, snapshot))) +goto cleanup; if (!vm-persistent snap-def-state != VIR_DOMAIN_RUNNING -- 2.4.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/8] test: Refactor test driver domain object retrieval
Add testDomObjFromDomainLocked and reuse it together with testDomObjFromDomain to retrieve domain objects in the qemu driver instead of open-coding it in every API. --- src/test/test_driver.c | 409 +++-- 1 file changed, 92 insertions(+), 317 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6613ed7..dc6e49a 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -477,13 +477,12 @@ static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool); static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); static virDomainObjPtr -testDomObjFromDomain(virDomainPtr domain) +testDomObjFromDomainLocked(testConnPtr driver, + virDomainPtr domain) { virDomainObjPtr vm; -testConnPtr driver = domain-conn-privateData; char uuidstr[VIR_UUID_STRING_BUFLEN]; -testDriverLock(driver); vm = virDomainObjListFindByUUIDRef(driver-domains, domain-uuid); if (!vm) { virUUIDFormat(domain-uuid, uuidstr); @@ -492,10 +491,22 @@ testDomObjFromDomain(virDomainPtr domain) uuidstr, domain-name); } -testDriverUnlock(driver); return vm; } +static virDomainObjPtr +testDomObjFromDomain(virDomainPtr domain) +{ +testConnPtr driver = domain-conn-privateData; +virDomainObjPtr ret; + +testDriverLock(driver); +ret = testDomObjFromDomainLocked(driver, domain); +testDriverUnlock(driver); + +return ret; +} + static char * testDomainGenerateIfname(virDomainDefPtr domdef) { @@ -1688,43 +1699,28 @@ static int testConnectNumOfDomains(virConnectPtr conn) static int testDomainIsActive(virDomainPtr dom) { -testConnPtr privconn = dom-conn-privateData; virDomainObjPtr obj; -int ret = -1; +int ret; -testDriverLock(privconn); -obj = virDomainObjListFindByUUID(privconn-domains, dom-uuid); -testDriverUnlock(privconn); -if (!obj) { -virReportError(VIR_ERR_NO_DOMAIN, NULL); -goto cleanup; -} -ret = virDomainObjIsActive(obj); +if (!(obj = testDomObjFromDomain(dom))) +return -1; - cleanup: -if (obj) -virObjectUnlock(obj); +ret = virDomainObjIsActive(obj); +virDomainObjEndAPI(obj); return ret; } static int testDomainIsPersistent(virDomainPtr dom) { -testConnPtr privconn = dom-conn-privateData; virDomainObjPtr obj; -int ret = -1; +int ret; + +if (!(obj = testDomObjFromDomain(dom))) +return -1; -testDriverLock(privconn); -obj = virDomainObjListFindByUUID(privconn-domains, dom-uuid); -testDriverUnlock(privconn); -if (!obj) { -virReportError(VIR_ERR_NO_DOMAIN, NULL); -goto cleanup; -} ret = obj-persistent; - cleanup: -if (obj) -virObjectUnlock(obj); +virDomainObjEndAPI(obj); return ret; } @@ -1885,13 +1881,9 @@ static int testDomainDestroy(virDomainPtr domain) int ret = -1; testDriverLock(privconn); -privdom = virDomainObjListFindByName(privconn-domains, - domain-name); -if (privdom == NULL) { -virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__); +if (!(privdom = testDomObjFromDomainLocked(privconn, domain))) goto cleanup; -} testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_DESTROYED); event = virDomainEventLifecycleNewFromObj(privdom, @@ -1917,15 +1909,8 @@ static int testDomainResume(virDomainPtr domain) virObjectEventPtr event = NULL; int ret = -1; -testDriverLock(privconn); -privdom = virDomainObjListFindByName(privconn-domains, - domain-name); -testDriverUnlock(privconn); - -if (privdom == NULL) { -virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__); -goto cleanup; -} +if (!(privdom = testDomObjFromDomain(domain))) +return -1; if (virDomainObjGetState(privdom, NULL) != VIR_DOMAIN_PAUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, _(domain '%s' not paused), @@ -1958,15 +1943,8 @@ static int testDomainSuspend(virDomainPtr domain) int ret = -1; int state; -testDriverLock(privconn); -privdom = virDomainObjListFindByName(privconn-domains, - domain-name); -testDriverUnlock(privconn); - -if (privdom == NULL) { -virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__); -goto cleanup; -} +if (!(privdom = testDomObjFromDomain(domain))) +return -1; state = virDomainObjGetState(privdom, NULL); if (state == VIR_DOMAIN_SHUTOFF || state == VIR_DOMAIN_PAUSED) { @@ -2003,13 +1981,9 @@ static int testDomainShutdownFlags(virDomainPtr domain, virCheckFlags(0, -1); testDriverLock(privconn); -privdom = virDomainObjListFindByName(privconn-domains, - domain-name); -if (privdom == NULL) { -
[libvirt] [PATCH 5/8] test: group domain APIs together
The test driver groups the API groups together, but some domain APIs were scattered around. --- src/test/test_driver.c | 225 + 1 file changed, 113 insertions(+), 112 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 20d3c71..59e2031 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3231,6 +3231,119 @@ static int testDomainInterfaceStats(virDomainPtr domain, return ret; } +static int testConnectListAllDomains(virConnectPtr conn, + virDomainPtr **domains, + unsigned int flags) +{ +testConnPtr privconn = conn-privateData; +int ret; + +virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1); + +testDriverLock(privconn); +ret = virDomainObjListExport(privconn-domains, conn, domains, + NULL, flags); +testDriverUnlock(privconn); + +return ret; +} + +static char * +testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED, + virStreamPtr st, + unsigned int screen ATTRIBUTE_UNUSED, + unsigned int flags) +{ +char *ret = NULL; + +virCheckFlags(0, NULL); + +if (VIR_STRDUP(ret, image/png) 0) +return NULL; + +if (virFDStreamOpenFile(st, PKGDATADIR /libvirtLogo.png, 0, 0, O_RDONLY) 0) +VIR_FREE(ret); + +return ret; +} + +static int +testDomainManagedSave(virDomainPtr dom, unsigned int flags) +{ +testConnPtr privconn = dom-conn-privateData; +virDomainObjPtr vm = NULL; +virObjectEventPtr event = NULL; +int ret = -1; + +virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE | + VIR_DOMAIN_SAVE_RUNNING | + VIR_DOMAIN_SAVE_PAUSED, -1); + +if (!(vm = testDomObjFromDomain(dom))) +return -1; + +if (!virDomainObjIsActive(vm)) { +virReportError(VIR_ERR_OPERATION_INVALID, + %s, _(domain is not running)); +goto cleanup; +} + +if (!vm-persistent) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(cannot do managed save for transient domain)); +goto cleanup; +} + +testDomainShutdownState(dom, vm, VIR_DOMAIN_SHUTOFF_SAVED); +event = virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_SAVED); +vm-hasManagedSave = true; + +ret = 0; + cleanup: +virDomainObjEndAPI(vm); +testObjectEventQueueUnlocked(privconn, event); + +return ret; +} + +static int +testDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) +{ +virDomainObjPtr vm; +int ret; + +virCheckFlags(0, -1); + +if (!(vm = testDomObjFromDomain(dom))) +return -1; + +ret = vm-hasManagedSave; + +virDomainObjEndAPI(vm); +return ret; +} + +static int +testDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags) +{ +virDomainObjPtr vm; + +virCheckFlags(0, -1); + +if (!(vm = testDomObjFromDomain(dom))) +return -1; + +vm-hasManagedSave = false; + +virDomainObjEndAPI(vm); +return 0; +} + +/* + * Network APIs + */ static virNetworkPtr testNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) @@ -5836,23 +5949,6 @@ testConnectNetworkEventDeregisterAny(virConnectPtr conn, return ret; } -static int testConnectListAllDomains(virConnectPtr conn, - virDomainPtr **domains, - unsigned int flags) -{ -testConnPtr privconn = conn-privateData; -int ret; - -virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1); - -testDriverLock(privconn); -ret = virDomainObjListExport(privconn-domains, conn, domains, - NULL, flags); -testDriverUnlock(privconn); - -return ret; -} - static int testNodeGetCPUMap(virConnectPtr conn, unsigned char **cpumap, @@ -5881,25 +5977,6 @@ testNodeGetCPUMap(virConnectPtr conn, return ret; } -static char * -testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED, - virStreamPtr st, - unsigned int screen ATTRIBUTE_UNUSED, - unsigned int flags) -{ -char *ret = NULL; - -virCheckFlags(0, NULL); - -if (VIR_STRDUP(ret, image/png) 0) -return NULL; - -if (virFDStreamOpenFile(st, PKGDATADIR /libvirtLogo.png, 0, 0, O_RDONLY) 0) -VIR_FREE(ret); - -return ret; -} - static int testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED, const char *arch, @@ -5910,82 +5987,6 @@ testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED, return cpuGetModels(arch, models); } -static int -testDomainManagedSave(virDomainPtr dom, unsigned int
[libvirt] [PATCH 4/8] test: Refactor test driver event sending
Make testObjectEventQueue tolerant to NULL @event and move it so that it does not require a prototype. Additionally add testObjectEventQueueUnlocked that will lock @driver before sending the event. Refactor the rest of the codebase to make use of the above features --- src/test/test_driver.c | 112 +++-- 1 file changed, 44 insertions(+), 68 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index dc6e49a..20d3c71 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -137,8 +137,6 @@ static const virNodeInfo defaultNodeInfo = { static int testConnectClose(virConnectPtr conn); -static void testObjectEventQueue(testConnPtr driver, - virObjectEventPtr event); static void testDriverLock(testConnPtr driver) { @@ -150,6 +148,28 @@ static void testDriverUnlock(testConnPtr driver) virMutexUnlock(driver-lock); } +static void testObjectEventQueue(testConnPtr driver, + virObjectEventPtr event) +{ +if (!event) +return; + +virObjectEventStateQueue(driver-eventState, event); +} + + +static void +testObjectEventQueueUnlocked(testConnPtr driver, + virObjectEventPtr event) +{ +if (!event) +return; + +testDriverLock(driver); +testObjectEventQueue(driver, event); +testDriverUnlock(driver); +} + static void *testDomainObjPrivateAlloc(void) { testDomainObjPrivatePtr priv; @@ -1774,8 +1794,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, cleanup: if (dom) virObjectUnlock(dom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); virDomainDefFree(def); testDriverUnlock(privconn); return ret; @@ -1896,8 +1915,7 @@ static int testDomainDestroy(virDomainPtr domain) ret = 0; cleanup: virDomainObjEndAPI(privdom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -1927,11 +1945,7 @@ static int testDomainResume(virDomainPtr domain) cleanup: virDomainObjEndAPI(privdom); -if (event) { -testDriverLock(privconn); -testObjectEventQueue(privconn, event); -testDriverUnlock(privconn); -} +testObjectEventQueueUnlocked(privconn, event); return ret; } @@ -1961,12 +1975,7 @@ static int testDomainSuspend(virDomainPtr domain) cleanup: virDomainObjEndAPI(privdom); - -if (event) { -testDriverLock(privconn); -testObjectEventQueue(privconn, event); -testDriverUnlock(privconn); -} +testObjectEventQueueUnlocked(privconn, event); return ret; } @@ -2002,8 +2011,7 @@ static int testDomainShutdownFlags(virDomainPtr domain, ret = 0; cleanup: virDomainObjEndAPI(privdom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -2070,8 +2078,7 @@ static int testDomainReboot(virDomainPtr domain, ret = 0; cleanup: virDomainObjEndAPI(privdom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -2214,8 +2221,7 @@ testDomainSaveFlags(virDomainPtr domain, const char *path, unlink(path); } virDomainObjEndAPI(privdom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -2319,8 +2325,7 @@ testDomainRestoreFlags(virConnectPtr conn, VIR_FORCE_CLOSE(fd); if (dom) virObjectUnlock(dom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -2389,8 +2394,7 @@ static int testDomainCoreDumpWithFormat(virDomainPtr domain, cleanup: VIR_FORCE_CLOSE(fd); virDomainObjEndAPI(privdom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -2817,8 +2821,7 @@ static virDomainPtr testDomainDefineXMLFlags(virConnectPtr conn, virDomainDefFree(oldDef); if (dom) virObjectUnlock(dom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -2938,8 +2941,7 @@ static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) cleanup: virDomainObjEndAPI(privdom); -if (event) -testObjectEventQueue(privconn, event); +testObjectEventQueue(privconn, event); testDriverUnlock(privconn); return ret; } @@ -3006,8 +3008,7 @@ static int
[libvirt] [[libvirt-php][PATCH v1] qemu-agent-command] fixes for installation and add another libvirt function
* add libvirt_domain_qemu_agent_command * fix install target, because before this all stuff goes to /usr/usr dir Signed-off-by: Vasiliy Tolstov v.tols...@selfip.ru --- configure.ac | 3 +++ src/Makefile.am | 19 ++- src/libvirt-php.c | 28 src/libvirt-php.h | 2 ++ 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 9e9fee0..0afa2e2 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,9 @@ PKG_PROG_PKG_CONFIG LIBVIRT_REQUIRED=0.6.2 PKG_CHECK_MODULES(LIBVIRT, libvirt = $LIBVIRT_REQUIRED) +PKG_CHECK_MODULES(QEMU, libvirt-qemu) +AC_SUBST([QEMU_CFLAGS]) +AC_SUBST([QEMU_LIBS]) dnl == dnl required minimum version of libxml2 diff --git a/src/Makefile.am b/src/Makefile.am index cab0456..f270ec2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,10 +6,10 @@ WL=@WL@ SHLIB_FLAGS=@SHLIB_FLAGS@ install-exec-local: - $(MKDIR_P) $(DESTDIR)$(prefix)$(PHPEDIR) - $(MKDIR_P) $(DESTDIR)$(prefix)$(PHPCDIR) - $(INSTALL) -m 644 -D .libs/$(PACKAGE).so $(DESTDIR)$(prefix)$(PHPEDIR)/$(PACKAGE).so - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)$(PHPCDIR) + $(MKDIR_P) $(DESTDIR)$(PHPEDIR) + $(MKDIR_P) $(DESTDIR)$(PHPCDIR) + $(INSTALL) -m 644 -D .libs/$(PACKAGE).so $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so + $(INSTALL) -m 755 -d $(DESTDIR)$(PHPCDIR) $(ECHO) extension=$(PACKAGE).so libvirt-php.ini $(ECHO) libvirt-php.ini $(ECHO) [libvirt] libvirt-php.ini @@ -19,21 +19,22 @@ install-exec-local: $(ECHO) libvirt.image_path=/var/lib/libvirt/images libvirt-php.ini $(ECHO) ; Limit maximum number of libvirt connections libvirt-php.ini $(ECHO) libvirt.max_connections=5 libvirt-php.ini - $(INSTALL) -m 644 -D libvirt-php.ini $(DESTDIR)$(prefix)$(PHPCDIR)/$(PACKAGE).ini + $(INSTALL) -m 644 -D libvirt-php.ini $(DESTDIR)$(PHPCDIR)/$(PACKAGE).ini uninstall-local: - $(RM) -f $(DESTDIR)$(prefix)$(PHPCDIR)/$(PACKAGE).ini - $(RM) -f $(DESTDIR)$(prefix)$(PHPEDIR)/$(PACKAGE).so + $(RM) -f $(DESTDIR)$(PHPCDIR)/$(PACKAGE).ini + $(RM) -f $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so AM_CFLAGS = \ $(PHPINC) $(LIBXML_CFLAGS) \ - $(LIBVIRT_CFLAGS) $(DEFINES) \ + $(LIBVIRT_CFLAGS) $(QEMU_CFLAGS) $(DEFINES) \ -I$(top_srcdir)/winsrc AM_LDFLAGS = \ $(SHLIB_LDFLAGS) \ $(LIBXML_LIBS) \ - $(LIBVIRT_LIBS) + $(LIBVIRT_LIBS) \ + $(QEMU_LIBS) lib_LTLIBRARIES = libvirt-php.la diff --git a/src/libvirt-php.c b/src/libvirt-php.c index d46fbb9..161abca 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -161,6 +161,7 @@ static zend_function_entry libvirt_functions[] = { PHP_FE(libvirt_domain_send_keys, NULL) PHP_FE(libvirt_domain_send_pointer_event, NULL) PHP_FE(libvirt_domain_update_device, NULL) + PHP_FE(libvirt_domain_qemu_agent_command, NULL) /* Domain snapshot functions */ PHP_FE(libvirt_domain_has_current_snapshot, NULL) PHP_FE(libvirt_domain_snapshot_create, NULL) @@ -3943,6 +3944,33 @@ PHP_FUNCTION(libvirt_domain_get_name) } /* + Function name: libvirt_domain_qemu_agent_command + Since version: 0.5.2(-1) + Description:Function is used to send qemu-ga command + Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*() + @timeout [int]: timeout for waiting (-2 block, -1 default, 0 no wait, 0 wait specific time + @flags [int]: ?? + Returns:String on success and FALSE on error +*/ +PHP_FUNCTION(libvirt_domain_qemu_agent_command) +{ + php_libvirt_domain *domain=NULL; + zval *zdomain; + const char *cmd; + int cmd_len; + char *ret; + long timeout = -1; + long flags = 0; + + GET_DOMAIN_FROM_ARGS(rs|l|l, zdomain, cmd, cmd_len, timeout, flags); + + ret = virDomainQemuAgentCommand(domain-domain, cmd, timeout, flags); + if (ret == NULL) RETURN_FALSE; + + RETURN_STRING(ret,0); +} + +/* Function name: libvirt_domain_get_uuid_string Since version: 0.4.1(-1) Description:Function is used to get the domain's UUID in string format diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 7c9a229..1d9c6ab 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -80,6 +80,7 @@ #include libvirt/libvirt.h #include libvirt/virterror.h +#include libvirt/libvirt-qemu.h #include libxml/parser.h #include libxml/xpath.h #include fcntl.h @@ -427,6 +428,7 @@ PHP_FUNCTION(libvirt_domain_send_keys); PHP_FUNCTION(libvirt_domain_send_pointer_event); PHP_FUNCTION(libvirt_domain_get_metadata); PHP_FUNCTION(libvirt_domain_set_metadata); +PHP_FUNCTION(libvirt_domain_qemu_agent_command); /* Domain snapshot functions */
[libvirt] [PATCH 7/7] qemu: Add check for unpriv sgio for SCSI generic host device
https://bugzilla.redhat.com/show_bug.cgi?id=1072736 Check if the hostdev has set the sgio filtered/unfiltered and handle appropriately. This restores functionality removed by commit id 'ce346623' to remove sgio support the SCSI generic host device. Note that this patch fixes a bug where if the virGetDeviceUnprivSGIO returned either 0 or 1 in 'val', the 'disk' would be dereferenced; however, since a hostdev didn't have one - that dereference would have caused a segfault. Instead these changes use the hostdev's sgio value. Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 14ea4c8..485f1cc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1276,6 +1276,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, { char *dev_path = NULL; char *key = NULL; +virDomainHostdevSubsysSCSIPtr scsisrc = hostdev-source.subsys.u.scsi; +virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; int ret = -1; if (!qemuIsSharedHostdev(hostdev)) @@ -1286,6 +1288,18 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, if (!(dev_path = qemuGetHostdevPath(hostdev))) goto cleanup; +if (virCheckUnprivSGIO(driver-sharedDevices, dev_path, + scsisrc-sgio) 0) { +if (virGetLastError() == NULL) { +virReportError(VIR_ERR_OPERATION_INVALID, + _(sgio of shared scsi host device '%s-%d-%d-%d' + conflicts with other active domains), + scsihostsrc-adapter, scsihostsrc-bus, + scsihostsrc-target, scsihostsrc-unit); +} +goto cleanup; +} + if (!(key = qemuGetSharedHostdevKey(dev_path))) goto cleanup; -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/7] qemu: Introduce qemuGetHostdevPath
Introduce a convenience function to handle formulating the hostdev path Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 21 - 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 8e9da0d..fd0ad3f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1208,15 +1208,13 @@ qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev) return false; } - static char * -qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev) +qemuGetHostdevPath(virDomainHostdevDefPtr hostdev) { virDomainHostdevSubsysSCSIPtr scsisrc = hostdev-source.subsys.u.scsi; virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; char *dev_name = NULL; char *dev_path = NULL; -char *key = NULL; if (!(dev_name = virSCSIDeviceGetDevName(NULL, scsihostsrc-adapter, @@ -1225,14 +1223,27 @@ qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev) scsihostsrc-unit))) goto cleanup; -if (virAsprintf(dev_path, /dev/%s, dev_name) 0) +ignore_value(virAsprintf(dev_path, /dev/%s, dev_name)); + + cleanup: +VIR_FREE(dev_name); +return dev_path; +} + + +static char * +qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev) +{ +char *key = NULL; +char *dev_path = NULL; + +if (!(dev_path = qemuGetHostdevPath(hostdev))) goto cleanup; if (!(key = qemuGetSharedDeviceKey(dev_path))) goto cleanup; cleanup: -VIR_FREE(dev_name); VIR_FREE(dev_path); return key; -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/7] qemu: Introduce qemuIsSharedHostdev
Add a single boolean function to handle whether the hostdev is shared or not Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 23 +++ 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 16ae6ab..8e9da0d 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1196,6 +1196,19 @@ qemuAddSharedDisk(virQEMUDriverPtr driver, } +static bool +qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev) +{ +if (hostdev-shareable +(hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS + hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI + hostdev-source.subsys.u.scsi.protocol != + VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)) +return true; +return false; +} + + static char * qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev) { @@ -1233,10 +1246,7 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, char *key = NULL; int ret = -1; -if (!hostdev-shareable || -!(hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS - hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI - hostdev-source.subsys.u.scsi.protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)) +if (!qemuIsSharedHostdev(hostdev)) return 0; if (!(key = qemuGetSharedHostdevKey(hostdev))) @@ -1337,10 +1347,7 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver, char *key = NULL; int ret; -if (!hostdev-shareable || -!(hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS - hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI - hostdev-source.subsys.u.scsi.protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)) +if (!qemuIsSharedHostdev(hostdev)) return 0; if (!(key = qemuGetSharedHostdevKey(hostdev))) -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 6/7] qemu: Add ability to set sgio values for hostdev
Add necessary checks in order to allow setting sgio values for a scsi host device Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 797e5f1..14ea4c8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1441,6 +1441,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) virDomainDiskDefPtr disk = NULL; virDomainHostdevDefPtr hostdev = NULL; char *sysfs_path = NULL; +char *hostdev_path = NULL; const char *path = NULL; int val = -1; int ret = 0; @@ -1459,19 +1460,13 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) } else if (dev-type == VIR_DOMAIN_DEVICE_HOSTDEV) { hostdev = dev-data.hostdev; +if (!qemuIsSharedHostdev(hostdev)) +return 0; -if (hostdev-mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS -hostdev-source.subsys.type == -VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI -hostdev-source.subsys.u.scsi.sgio) { -virReportError(VIR_ERR_INTERNAL_ERROR, %s, - _('sgio' is not supported for SCSI - generic device yet )); -ret = -1; +if (!(hostdev_path = qemuGetHostdevPath(hostdev))) goto cleanup; -} -return 0; +path = hostdev_path; } else { return 0; } @@ -1483,7 +1478,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) } /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */ -val = (disk-sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); +if (dev-type == VIR_DOMAIN_DEVICE_DISK) +val = (disk-sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); +else +val = (hostdev-source.subsys.u.scsi.sgio == + VIR_DOMAIN_DEVICE_SGIO_UNFILTERED); /* Do not do anything if unpriv_sgio is not supported by the kernel and the * whitelist is enabled. But if requesting unfiltered access, always call @@ -1494,6 +1493,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) ret = -1; cleanup: +VIR_FREE(hostdev_path); VIR_FREE(sysfs_path); return ret; } -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 5/7] qemu: Extract qemuGetHostdevPath from qemuGetSharedHostdevKey
The device path will be necessary for upcoming patch to allow sgio settings on a hostdev Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index faa0b49..797e5f1 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1258,20 +1258,14 @@ qemuGetHostdevPath(virDomainHostdevDefPtr hostdev) static char * -qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev) +qemuGetSharedHostdevKey(const char *dev_path) { char *key = NULL; -char *dev_path = NULL; - -if (!(dev_path = qemuGetHostdevPath(hostdev))) -goto cleanup; if (!(key = qemuGetSharedDeviceKey(dev_path))) goto cleanup; cleanup: -VIR_FREE(dev_path); - return key; } @@ -1280,6 +1274,7 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, virDomainHostdevDefPtr hostdev, const char *name) { +char *dev_path = NULL; char *key = NULL; int ret = -1; @@ -1288,7 +1283,10 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, qemuDriverLock(driver); -if (!(key = qemuGetSharedHostdevKey(hostdev))) +if (!(dev_path = qemuGetHostdevPath(hostdev))) +goto cleanup; + +if (!(key = qemuGetSharedHostdevKey(dev_path))) goto cleanup; if (qemuSharedDeviceEntryInsert(driver, key, name) 0) @@ -1298,6 +1296,7 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, cleanup: qemuDriverUnlock(driver); +VIR_FREE(dev_path); VIR_FREE(key); return ret; } @@ -1386,6 +1385,7 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver, virDomainHostdevDefPtr hostdev, const char *name) { +char *dev_path = NULL; char *key = NULL; int ret = -1; @@ -1394,7 +1394,10 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver, qemuDriverLock(driver); -if (!(key = qemuGetSharedHostdevKey(hostdev))) +if (!(dev_path = qemuGetHostdevPath(hostdev))) +goto cleanup; + +if (!(key = qemuGetSharedHostdevKey(dev_path))) goto cleanup; if (qemuSharedDeviceEntryRemove(driver, key, name) 0) @@ -1403,6 +1406,7 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver, ret = 0; cleanup: qemuDriverUnlock(driver); +VIR_FREE(dev_path); VIR_FREE(key); return ret; } -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/7] qemu: Refactor qemuAddSharedHostdev and qemuRemoveSharedHostdev
Refactor the functions to follow logic from qemuAddSharedDisk and qemuRemoveSharedDisk with respect to locking driver. Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 0314707..faa0b49 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1286,13 +1286,18 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, if (!qemuIsSharedHostdev(hostdev)) return 0; +qemuDriverLock(driver); + if (!(key = qemuGetSharedHostdevKey(hostdev))) -return -1; +goto cleanup; -qemuDriverLock(driver); -ret = qemuSharedDeviceEntryInsert(driver, key, name); -qemuDriverUnlock(driver); +if (qemuSharedDeviceEntryInsert(driver, key, name) 0) +goto cleanup; + +ret = 0; + cleanup: +qemuDriverUnlock(driver); VIR_FREE(key); return ret; } @@ -1382,18 +1387,22 @@ qemuRemoveSharedHostdev(virQEMUDriverPtr driver, const char *name) { char *key = NULL; -int ret; +int ret = -1; if (!qemuIsSharedHostdev(hostdev)) return 0; +qemuDriverLock(driver); + if (!(key = qemuGetSharedHostdevKey(hostdev))) -return -1; +goto cleanup; -qemuDriverLock(driver); -ret = qemuSharedDeviceEntryRemove(driver, key, name); -qemuDriverUnlock(driver); +if (qemuSharedDeviceEntryRemove(driver, key, name) 0) +goto cleanup; +ret = 0; + cleanup: +qemuDriverUnlock(driver); VIR_FREE(key); return ret; } -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/7] qemu: Refactor qemuCheckSharedDisk to create virCheckUnprivSGIO
Split out the SGIO check for sharing with hostdev in future patches Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 88 ++-- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index fd0ad3f..0314707 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1013,26 +1013,21 @@ qemuGetSharedDeviceKey(const char *device_path) return key; } -/* Check if a shared device's setting conflicts with the conf - * used by other domain(s). Currently only checks the sgio - * setting. Note that this should only be called for disk with - * block source if the device type is disk. - * - * Returns 0 if no conflicts, otherwise returns -1. +/* + * Make necessary checks for the need to check and for the current setting + * of the 'unpriv_sgio' value for the device_path passed. */ static int -qemuCheckSharedDisk(virHashTablePtr sharedDevices, -virDomainDiskDefPtr disk) +virCheckUnprivSGIO(virHashTablePtr sharedDevices, + const char *device_path, + int sgio) { char *sysfs_path = NULL; char *key = NULL; int val; int ret = -1; -if (disk-device != VIR_DOMAIN_DISK_DEVICE_LUN) -return 0; - -if (!(sysfs_path = virGetUnprivSGIOSysfsPath(disk-src-path, NULL))) +if (!(sysfs_path = virGetUnprivSGIOSysfsPath(device_path, NULL))) goto cleanup; /* It can't be conflict if unpriv_sgio is not supported by kernel. */ @@ -1041,7 +1036,7 @@ qemuCheckSharedDisk(virHashTablePtr sharedDevices, goto cleanup; } -if (!(key = qemuGetSharedDeviceKey(disk-src-path))) +if (!(key = qemuGetSharedDeviceKey(device_path))) goto cleanup; /* It can't be conflict if no other domain is sharing it. */ @@ -1050,29 +1045,19 @@ qemuCheckSharedDisk(virHashTablePtr sharedDevices, goto cleanup; } -if (virGetDeviceUnprivSGIO(disk-src-path, NULL, val) 0) +if (virGetDeviceUnprivSGIO(device_path, NULL, val) 0) goto cleanup; +/* Error message on failure needs to be handled in caller + * since there is more specific knowledge of device + */ +virResetLastError(); if (!((val == 0 - (disk-sgio == VIR_DOMAIN_DEVICE_SGIO_FILTERED || -disk-sgio == VIR_DOMAIN_DEVICE_SGIO_DEFAULT)) || + (sgio == VIR_DOMAIN_DEVICE_SGIO_FILTERED || +sgio == VIR_DOMAIN_DEVICE_SGIO_DEFAULT)) || (val == 1 - disk-sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED))) { - -if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_VOLUME) { -virReportError(VIR_ERR_OPERATION_INVALID, - _(sgio of shared disk 'pool=%s' 'volume=%s' conflicts - with other active domains), - disk-src-srcpool-pool, - disk-src-srcpool-volume); -} else { -virReportError(VIR_ERR_OPERATION_INVALID, - _(sgio of shared disk '%s' conflicts with other - active domains), disk-src-path); -} - + sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED))) goto cleanup; -} ret = 0; @@ -1083,6 +1068,47 @@ qemuCheckSharedDisk(virHashTablePtr sharedDevices, } +/* Check if a shared device's setting conflicts with the conf + * used by other domain(s). Currently only checks the sgio + * setting. Note that this should only be called for disk with + * block source if the device type is disk. + * + * Returns 0 if no conflicts, otherwise returns -1. + */ +static int +qemuCheckSharedDisk(virHashTablePtr sharedDevices, +virDomainDiskDefPtr disk) +{ +int ret = -1; + +if (disk-device != VIR_DOMAIN_DISK_DEVICE_LUN) +return 0; + +if (virCheckUnprivSGIO(sharedDevices, disk-src-path, disk-sgio) 0) { +if (virGetLastError() == NULL) { +if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_VOLUME) { +virReportError(VIR_ERR_OPERATION_INVALID, + _(sgio of shared disk 'pool=%s' 'volume=%s' + conflicts with other active domains), + disk-src-srcpool-pool, + disk-src-srcpool-volume); +} else { +virReportError(VIR_ERR_OPERATION_INVALID, + _(sgio of shared disk '%s' conflicts with + other active domains), + disk-src-path); +} +} +goto cleanup; +} + +ret = 0; + + cleanup: +return ret; +} + + bool qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry, const char *name, -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com
[libvirt] [PATCH 0/7] Restore code to allow unpriv_sgio for hostdev SCSI generic
https://bugzilla.redhat.com/show_bug.cgi?id=1072736 This series of patches unreverts the functionality from commit id 'ce346623' which reverted the original functionality. Since pure revert caused too many conflicts and because the code has undergone a few changes since the prior reversion, I had to restore the code by rote method. The reversion includes some refactorings to make the final check much easier to handle. Of note patch 3 covers much of what was adjusted in the reverted patch 'qemuCheckSharedDevice'. Patch 4 expands the driver lock to cover the same space as the similar disk code - I can take the other as well and shorten the time the disk code has the lock. Keeping them similar is mostly a sanity thing. John Ferlan (7): qemu: Introduce qemuIsSharedHostdev qemu: Introduce qemuGetHostdevPath qemu: Refactor qemuCheckSharedDisk to create virCheckUnprivSGIO qemu: Refactor qemuAddSharedHostdev and qemuRemoveSharedHostdev qemu: Extract qemuGetHostdevPath from qemuGetSharedHostdevKey qemu: Add ability to set sgio values for hostdev qemu: Add check for unpriv sgio for SCSI generic host device src/qemu/qemu_conf.c | 205 ++- 1 file changed, 138 insertions(+), 67 deletions(-) -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC] libvirt hugepage hooks
Hi, This is very rough and early, but I wanted to get some feedback, possibly advice, and see if there's some interest in at least creating infrastructure for user contributed libvirt hooks, if not some default ones that are no-ops unless configured. The impetus for this is that I started trying to tune a dual-socket system for performance with device assignment and quickly became very frustrated that distros don't provide any built-in support for more than the very basics of hugepages. Yes, there are kernel commandline options, but those don't allow node specific configuration. Yes, there's 'virsh allocpages', but how does that get incorporated automatically into initializing libvirtd or a domain? Creating any sort of persistence for hugepages is an exercise for the user. So I think the first step in this is that the hooks scripts[1] should by default support sub-scripts in the common way, with a .d sub-directory holding those scripts, for example daemon.d and qemu.d. In the attached file, I've simply commandeered the default script to call the sub-scripts. For compatibility (ie. not overwriting user scripts), that should probably happen within libvirt. In any case, a single monolithic hook file is impossible to maintain on a system, let alone multiple systems, so this needs to be brought up to date. The second step is that even if we drop user contrib hooks out in /usr/share for admins to pull in as desired, perhaps we can provide some consistency for how to configure those hooks. In the example below I propose /etc/sysconfig/libvirt-hook-config.xml. You can see how currently it supports static and dynamic hugepage hooks, static occurring through the daemon hook and dynamic through the qemu hook. Ideally the dynamic hook would simply list the domain names participating in dynamic hugepages and figure out what needs to be allocated where from the domain xml. I haven't gotten that far (and frankly trying to satisfy cpu/numa vs numatune/memory|memnode vs memoryBacking/hugepages and memory size still looks very confusing to me). Do we want a common place to configure this sort of thing? Is XML the right format? On to the scripts themselves. I got some advice on #virt that I should use 'virsh allocpages' to manage hugepages. Despite the warning not to call into libvirt in the hook documentation[1], I was assured it'd be ok here. However, somehow 'virsh freepages' did manage to hang and my RHEL7.1 system doesn't support allocpages yet, so my prototype uses raw sysfs. AFAICT, any sort of hugepage manipulation is inherently broken because of the racy kernel interfaces. We really need a hugepage broker, but that's well beyond the scope of libvirt. Functionally this seems to work well for me. I don't know how practical it is to support dynamic 1G pages; I'd probably encourage static setup for that as my system only survived a couple rounds before getting too fragmented. 2M dynamic seems to work quite nicely though. TL;DR, I thought I'd post this, even in a rough state to see if there's interest, get nitpicks at my terrible scripting, and make sure I'm not just scratching my own itch. Thanks, Alex [1] https://www.libvirt.org/hooks.html libvirt-hook-config.xml Description: XML document daemon Description: application/shellscript qemu Description: application/shellscript static-hugepages.sh Description: application/shellscript dynamic-hugepages.sh Description: application/shellscript -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 04/10] conf: use virDomainChrSourceDef to save the path
As the backend of shmem server is a unix type chr device, save it in virDomainChrSourceDef can reuse the exist code for chr device. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/conf/domain_conf.c | 8 +--- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 16 +++- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60d4d07..306b718 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1945,7 +1945,7 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def) return; virDomainDeviceInfoClear(def-info); -VIR_FREE(def-server.path); +virDomainChrSourceDefClear(def-server.chr); VIR_FREE(def-name); VIR_FREE(def); } @@ -11042,8 +11042,10 @@ virDomainShmemDefParseXML(xmlNodePtr node, if ((server = virXPathNode(./server[1], ctxt))) { def-server.enabled = true; +def-server.chr.type = VIR_DOMAIN_CHR_TYPE_UNIX; +def-server.chr.data.nix.listen = false; if ((tmp = virXMLPropString(server, path))) -def-server.path = virFileSanitizePath(tmp); +def-server.chr.data.nix.path = virFileSanitizePath(tmp); VIR_FREE(tmp); } @@ -19997,7 +1,7 @@ virDomainShmemDefFormat(virBufferPtr buf, if (def-server.enabled) { virBufferAddLit(buf, server); -virBufferEscapeString(buf, path='%s', def-server.path); +virBufferEscapeString(buf, path='%s', def-server.chr.data.nix.path); virBufferAddLit(buf, /\n); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ba17a8d..a4b1bf3 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1599,7 +1599,7 @@ struct _virDomainShmemDef { unsigned long long size; struct { bool enabled; -char *path; +virDomainChrSourceDef chr; } server; struct { bool enabled; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0414f77..5d55794 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8500,24 +8500,14 @@ qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem, virQEMUCapsPtr qemuCaps) { char *devstr = NULL; -virDomainChrSourceDef source = { -.type = VIR_DOMAIN_CHR_TYPE_UNIX, -.data.nix = { -.path = shmem-server.path, -.listen = false, -} -}; -if (!shmem-server.path -virAsprintf(source.data.nix.path, +if (!shmem-server.chr.data.nix.path +virAsprintf(shmem-server.chr.data.nix.path, /var/lib/libvirt/shmem-%s-sock, shmem-name) 0) return NULL; -devstr = qemuBuildChrChardevStr(source, shmem-info.alias, qemuCaps); - -if (!shmem-server.path) -VIR_FREE(source.data.nix.path); +devstr = qemuBuildChrChardevStr(shmem-server.chr, shmem-info.alias, qemuCaps); return devstr; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/5] Print SCSI logical unit as unsigned integer
The logical unit field is an unsigned integer, we should use the appropriate substitution when printing it. Signed-off-by: Eric Farman far...@linux.vnet.ibm.com --- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 2 +- src/qemu/qemu_hotplug.c | 4 ++-- src/util/virhostdev.c | 6 +++--- src/util/virscsi.c | 6 +++--- tools/virsh-domain.c| 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 1900039..c94cae8 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -427,7 +427,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, } else { virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; -if (virAsprintfQuiet(address, %s:%d:%d:%d, +if (virAsprintfQuiet(address, %s:%d:%d:%u, scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit) 0) { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9e77b87..7e3ca36 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18940,7 +18940,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, virBufferAsprintf(buf, adapter name='%s'/\n, scsihostsrc-adapter); virBufferAsprintf(buf, - address %sbus='%d' target='%d' unit='%d'/\n, + address %sbus='%d' target='%d' unit='%u'/\n, includeTypeInAddr ? type='scsi' : , scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index cc86a3b..1d538a0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1938,7 +1938,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, } else { virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; virReportError(VIR_ERR_INTERNAL_ERROR, - _(Unable to prepare scsi hostdev: %s:%d:%d:%d), + _(Unable to prepare scsi hostdev: %s:%d:%d:%u), scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit); } @@ -3873,7 +3873,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver, virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; virReportError(VIR_ERR_OPERATION_FAILED, -_(host scsi device %s:%d:%d.%d not found), +_(host scsi device %s:%d:%d.%u not found), scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit); } diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 1c8f31e..ea0076c 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -1482,7 +1482,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr hostdev_mgr, scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit, hostdev-readonly, hostdev-shareable))) { -VIR_WARN(Unable to reattach SCSI device %s:%d:%d:%d on domain %s, +VIR_WARN(Unable to reattach SCSI device %s:%d:%d:%u on domain %s, scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit, dom_name); return; @@ -1492,7 +1492,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr hostdev_mgr, * because qemuProcessStart could fail half way through. */ if (!(tmp = virSCSIDeviceListFind(hostdev_mgr-activeSCSIHostdevs, scsi))) { -VIR_WARN(Unable to find device %s:%d:%d:%d +VIR_WARN(Unable to find device %s:%d:%d:%u in list of active SCSI devices, scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit); @@ -1500,7 +1500,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr hostdev_mgr, return; } -VIR_DEBUG(Removing %s:%d:%d:%d dom=%s from activeSCSIHostdevs, +VIR_DEBUG(Removing %s:%d:%d:%u dom=%s from activeSCSIHostdevs, scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit, dom_name); diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 9f5cf0d..6c8b6ce 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -123,7 +123,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix, return NULL; if (virAsprintf(path, -%s/%d:%d:%d:%d/scsi_generic, +
[libvirt] [PATCH 0/5 v2] Corrections to SCSI logical unit handling
While working with the hostdev tag and SCSI LUNs, a problem was discovered with the XML schema (see commit message in patch 4). This spawned some further corrections to the handling of the logical unit field throughout libvirt. This series was split from a single patch, from this feedback: http://www.redhat.com/archives/libvir-list/2015-June/msg00489.html Eric Farman (5): Print SCSI logical unit as a positive integer Print SCSI logical unit as unsigned integer Convert SCSI logical unit from int to long long docs: Fix XML schema handling of LUN address in hostdev tag docs: Correct typos in scsi hostdev and address elements docs/formatdomain.html.in | 10 +++--- docs/schemas/domaincommon.rng | 14 -- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c| 4 ++-- src/conf/domain_conf.h| 2 +- src/qemu/qemu_command.h | 2 +- src/qemu/qemu_hotplug.c | 4 ++-- src/util/virhostdev.c | 6 +++--- src/util/virscsi.c| 16 src/util/virscsi.h| 8 tests/testutilsqemu.c | 2 +- tools/virsh-domain.c | 6 +++--- 12 files changed, 45 insertions(+), 31 deletions(-) -- 1.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/5] Print SCSI logical unit as a positive integer
A logical unit address is a positive integer, so it would be wise to reject any negative inputs. Signed-off-by: Eric Farman far...@linux.vnet.ibm.com --- src/conf/domain_conf.c | 2 +- tools/virsh-domain.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ca55981..9e77b87 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4954,7 +4954,7 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, goto cleanup; } -if (virStrToLong_ui(unit, NULL, 0, scsihostsrc-unit) 0) { +if (virStrToLong_uip(unit, NULL, 0, scsihostsrc-unit) 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _(cannot parse unit '%s'), unit); goto cleanup; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 4c47473..0bea462 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -488,7 +488,7 @@ static int str2SCSIAddress(const char *str, struct SCSIAddress *scsiAddr) return -1; unit++; -if (virStrToLong_ui(unit, NULL, 0, scsiAddr-unit) != 0) +if (virStrToLong_uip(unit, NULL, 0, scsiAddr-unit) != 0) return -1; return 0; -- 1.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/5] docs: Fix XML schema handling of LUN address in hostdev tag
Defining a domain with a SCSI disk attached via a hostdev tag and a source address unit value longer than two digits causes an error when editing the domain with virsh edit, even if no changes are made to the domain definition. The error suggests invalid XML, somewhere: # virsh edit lmb_guest error: XML document failed to validate against schema: Unable to validate doc against /usr/local/share/libvirt/schemas/domain.rng Extra element devices in interleave Element domain failed to validate content The virt-xml-validate tool fails with a similar error: # virt-xml-validate lmb_guest.xml Relax-NG validity error : Extra element devices in interleave lmb_guest.xml:17: element devices: Relax-NG validity error : Element domain failed to validate content lmb_guest.xml fails to validate The hostdev tag requires a source address to be specified, which includes bus, target, and unit address attributes. According to the SCSI Architecture Model spec (section 4.9 of SAM-2), a LUN address is 64 bits and thus could be up to 20 decimal digits long. Unfortunately, the XML schema limits this string to just two digits. Similarly, the target field can be up to 32 bits in length, which would be 10 decimal digits. # lsscsi -xx [0:0:19:0x40224011] diskIBM 2107900 3.44 /dev/sda # lsscsi [0:0:19:1074872354]diskIBM 2107900 3.44 /dev/sda # cat lmb_guest.xml domain type='kvm' namelmb_guest/name memory unit='MiB'1024/memory ...trimmed... devices controller type='scsi' model='virtio-scsi' index='0'/ hostdev mode='subsystem' type='scsi' source adapter name='scsi_host0'/ address bus='0' target='19' unit='1074872354'/ /source /hostdev ...trimmed... Since the reference unit and target fields are used in several places in the XML schema, create a separate one specific for SCSI Logical Units that will permit the greater length. This permits both the validation utility and the virsh edit command to succeed when a hostdev tag is included. Signed-off-by: Eric Farman far...@linux.vnet.ibm.com Reviewed-by: Matthew Rosato mjros...@linux.vnet.ibm.com Reviewed-by: Stefan Zimmermann s...@linux.vnet.ibm.com Reviewed-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com --- docs/formatdomain.html.in | 6 +- docs/schemas/domaincommon.rng | 14 -- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 4e85b51..c88c4a6 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3256,7 +3256,11 @@ /dd dtscsi/dt ddSCSI devices are described by both the codeadapter/code -and codeaddress/code elements. +and codeaddress/code elements. The codeaddress/code +element includes a codebus/code attribute (a 2-digit bus +number), a codetarget/code attribute (a 10-digit target +number), and a codeunit/code attribute (a 20-digit unit +number on the bus). p span class=sinceSince 1.2.8/span, the codesource/code element of a SCSI device may contain the codeprotocol/code diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f0f7400..b3c5cb8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3833,10 +3833,10 @@ ref name=driveBus/ /attribute attribute name=target - ref name=driveTarget/ + ref name=driveSCSITarget/ /attribute attribute name=unit - ref name=driveUnit/ + ref name=driveSCSIUnit/ /attribute /define define name=usbportaddress @@ -5129,11 +5129,21 @@ param name=pattern[0-9]{1,2}/param /data /define + define name=driveSCSITarget +data type=string + param name=pattern[0-9]{1,10}/param +/data + /define define name=driveUnit data type=string param name=pattern[0-9]{1,2}/param /data /define + define name=driveSCSIUnit +data type=string + param name=pattern[0-9]{1,20}/param +/data + /define define name=featureName data type=string param name='pattern'[a-zA-Z0-9\-_\.]+/param -- 1.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 5/5] docs: Correct typos in scsi hostdev and address elements
The type='scsi' parameter of an address element is ignored if placed within a hostdev section, and rejected by the XML schema used by virt-xml-validate. Remove it from the doc, and correct a typo in the remaining address arguments. Signed-off-by: Eric Farman far...@linux.vnet.ibm.com Reviewed-by: Matthew Rosato mjros...@linux.vnet.ibm.com Reviewed-by: Stefan Zimmermann s...@linux.vnet.ibm.com Reviewed-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com --- docs/formatdomain.html.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c88c4a6..f97a049 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2839,7 +2839,7 @@ ddDrive addresses have the following additional attributes: codecontroller/code (a 2-digit controller number), codebus/code (a 2-digit bus number), -codetarget/code (a 2-digit bus number), +codetarget/code (a 2-digit target number), and codeunit/code (a 2-digit unit number on the bus). /dd dtcodetype='virtio-serial'/code/dt @@ -3148,7 +3148,7 @@ lt;hostdev mode='subsystem' type='scsi' sgio='filtered' rawio='yes'gt; lt;sourcegt; lt;adapter name='scsi_host0'/gt; -lt;address type='scsi' bus='0' target='0' unit='0'/gt; +lt;address bus='0' target='0' unit='0'/gt; lt;/sourcegt; lt;readonly/gt; lt;address type='drive' controller='0' bus='0' target='0' unit='0'/gt; -- 1.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/5] Convert SCSI logical unit from int to long long
The SCSI Architecture Model defines a logical unit address as 64-bits in length, so change the field accordingly so that the entire value could be stored. Signed-off-by: Eric Farman far...@linux.vnet.ibm.com --- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.h | 2 +- src/qemu/qemu_hotplug.c | 4 ++-- src/util/virhostdev.c | 6 +++--- src/util/virscsi.c | 16 src/util/virscsi.h | 8 tests/testutilsqemu.c | 2 +- tools/virsh-domain.c| 6 +++--- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index c94cae8..e5d7e15 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -427,7 +427,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, } else { virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; -if (virAsprintfQuiet(address, %s:%d:%d:%u, +if (virAsprintfQuiet(address, %s:%d:%d:%llu, scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit) 0) { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7e3ca36..3f0f175 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4954,7 +4954,7 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, goto cleanup; } -if (virStrToLong_uip(unit, NULL, 0, scsihostsrc-unit) 0) { +if (virStrToLong_ullp(unit, NULL, 0, scsihostsrc-unit) 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _(cannot parse unit '%s'), unit); goto cleanup; @@ -18940,7 +18940,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, virBufferAsprintf(buf, adapter name='%s'/\n, scsihostsrc-adapter); virBufferAsprintf(buf, - address %sbus='%d' target='%d' unit='%u'/\n, + address %sbus='%d' target='%d' unit='%llu'/\n, includeTypeInAddr ? type='scsi' : , scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ba17a8d..f677c2e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -463,7 +463,7 @@ struct _virDomainHostdevSubsysSCSIHost { char *adapter; unsigned bus; unsigned target; -unsigned unit; +unsigned long long unit; }; typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 0fc59a8..6e0c3a3 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -63,7 +63,7 @@ struct _qemuBuildCommandLineCallbacks { const char *adapter, unsigned int bus, unsigned int target, - unsigned int unit); + unsigned long long unit); }; extern qemuBuildCommandLineCallbacks buildCommandLineCallbacks; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1d538a0..d5a40aa 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1938,7 +1938,7 @@ qemuDomainAttachHostSCSIDevice(virConnectPtr conn, } else { virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; virReportError(VIR_ERR_INTERNAL_ERROR, - _(Unable to prepare scsi hostdev: %s:%d:%d:%u), + _(Unable to prepare scsi hostdev: %s:%d:%d:%llu), scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit); } @@ -3873,7 +3873,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver, virDomainHostdevSubsysSCSIHostPtr scsihostsrc = scsisrc-u.host; virReportError(VIR_ERR_OPERATION_FAILED, -_(host scsi device %s:%d:%d.%u not found), +_(host scsi device %s:%d:%d.%llu not found), scsihostsrc-adapter, scsihostsrc-bus, scsihostsrc-target, scsihostsrc-unit); } diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index ea0076c..aa06b4a 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -1482,7 +1482,7 @@ virHostdevReAttachSCSIHostDevices(virHostdevManagerPtr hostdev_mgr,
[libvirt] [PATCH 09/10] qemu: Implement shared memory device hot-unplug
Signed-off-by: Luyao Huang lhu...@redhat.com --- src/qemu/qemu_driver.c | 6 ++-- src/qemu/qemu_hotplug.c | 96 - src/qemu/qemu_hotplug.h | 3 ++ 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b5a0be0..7c585a3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7887,6 +7887,9 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_MEMORY: ret = qemuDomainDetachMemoryDevice(driver, vm, dev-data.memory); break; +case VIR_DOMAIN_DEVICE_SHMEM: +ret = qemuDomainDetachShmemDevice(driver, vm, dev-data.shmem); +break; case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -7898,7 +7901,6 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: -case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: @@ -8315,7 +8317,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, case VIR_DOMAIN_DEVICE_SHMEM: if ((idx = virDomainShmemFind(vmdef, dev-data.shmem)) 0) { virReportError(VIR_ERR_OPERATION_FAILED, %s, - _(no matching share memory device was found)); + _(no matching shared memory device was found)); return -1; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 188807e..0f996c3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3298,6 +3298,47 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver, } +static int +qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver, +virDomainObjPtr vm, +virDomainShmemDefPtr shmem) +{ +virObjectEventPtr event; +char *charAlias = NULL; +qemuDomainObjPrivatePtr priv = vm-privateData; +ssize_t idx; +int rc = 0; + +VIR_DEBUG(Removing shared memory device %s from domain %p %s, + shmem-info.alias, vm, vm-def-name); + +if (shmem-server.enabled) { +if (virAsprintf(charAlias, char%s, shmem-info.alias) 0) +return -1; + +qemuDomainObjEnterMonitor(driver, vm); +rc = qemuMonitorDetachCharDev(priv-mon, charAlias); +VIR_FREE(charAlias); +if (qemuDomainObjExitMonitor(driver, vm) 0) +return -1; +} + +virDomainAuditShmem(vm, shmem, NULL, detach, rc == 0); + +if (rc 0) +return -1; + +if ((event = virDomainEventDeviceRemovedNewFromObj(vm, shmem-info.alias))) +qemuDomainEventQueue(driver, event); + +if ((idx = virDomainShmemFind(vm-def, shmem)) = 0) +virDomainShmemRemove(vm-def, idx); +qemuDomainReleaseDeviceAddress(vm, shmem-info, NULL); +virDomainShmemDefFree(shmem); +return 0; +} + + int qemuDomainRemoveDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3329,6 +3370,10 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, ret = qemuDomainRemoveMemoryDevice(driver, vm, dev-data.memory); break; +case VIR_DOMAIN_DEVICE_SHMEM: +ret = qemuDomainRemoveShmemDevice(driver, vm, dev-data.shmem); +break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: @@ -3342,7 +3387,6 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: -case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: @@ -4335,3 +4379,53 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver, qemuDomainResetDeviceRemoval(vm); return ret; } + + +int +qemuDomainDetachShmemDevice(virQEMUDriverPtr driver, +virDomainObjPtr vm, +virDomainShmemDefPtr shmem) +{ +qemuDomainObjPrivatePtr priv = vm-privateData; +ssize_t idx; +virDomainShmemDefPtr tmpshmem; +int rc; +int ret = -1; + +if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE)) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(qemu does not support -device)); +return -1; +} + +if ((idx = virDomainShmemFind(vm-def, shmem)) 0) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(device not present in domain configuration)); +return -1; +} + +tmpshmem = vm-def-shmems[idx]; + +if (!tmpshmem-info.alias) { +virReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(alias not set for shared memory device)); +return -1; +} + +qemuDomainMarkDeviceForRemoval(vm, tmpshmem-info); + +qemuDomainObjEnterMonitor(driver,
[libvirt] [PATCH 06/10] conf: Add helpers to insert/remove/find shmem devices in domain def
The helpers will be useful when implementing hotplug and coldplug of shared memory devices. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/conf/domain_conf.c | 61 src/conf/domain_conf.h | 7 ++ src/libvirt_private.syms | 3 +++ 3 files changed, 71 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 306b718..8a8e4f7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13343,6 +13343,67 @@ virDomainMemoryRemove(virDomainDefPtr def, } +int +virDomainShmemInsert(virDomainDefPtr def, + virDomainShmemDefPtr shmem) +{ +return VIR_APPEND_ELEMENT(def-shmems, def-nshmems, shmem); +} + + +ssize_t +virDomainShmemFind(virDomainDefPtr def, + virDomainShmemDefPtr shmem) +{ +size_t i; + +for (i = 0; i def-nshmems; i++) { + virDomainShmemDefPtr tmpshmem = def-shmems[i]; + + if (STRNEQ_NULLABLE(shmem-name, tmpshmem-name)) + continue; + + if (shmem-size != tmpshmem-size) + continue; + + if (shmem-server.enabled != tmpshmem-server.enabled || + (shmem-server.enabled + STRNEQ_NULLABLE(shmem-server.chr.data.nix.path, + tmpshmem-server.chr.data.nix.path))) + continue; + + if (shmem-msi.enabled != tmpshmem-msi.enabled || + (shmem-msi.enabled + (shmem-msi.vectors != tmpshmem-msi.vectors || + shmem-msi.ioeventfd != tmpshmem-msi.ioeventfd))) + continue; + +if (shmem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE +!virDomainDeviceInfoAddressIsEqual(shmem-info, tmpshmem-info)) +continue; + +break; +} + +if (i def-nshmems) +return i; + +return -1; +} + + +virDomainShmemDefPtr +virDomainShmemRemove(virDomainDefPtr def, + size_t idx) +{ +virDomainShmemDefPtr ret = def-shmems[idx]; + +VIR_DELETE_ELEMENT(def-shmems, idx, def-nshmems); + +return ret; +} + + char * virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a4b1bf3..39bc928 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2943,6 +2943,13 @@ int virDomainMemoryFindInactiveByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +int virDomainShmemInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +ssize_t virDomainShmemFind(virDomainDefPtr def, virDomainShmemDefPtr shmem) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +virDomainShmemDefPtr virDomainShmemRemove(virDomainDefPtr def, size_t idx) +ATTRIBUTE_NONNULL(1); + VIR_ENUM_DECL(virDomainTaint) VIR_ENUM_DECL(virDomainVirt) VIR_ENUM_DECL(virDomainBoot) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3ceb4e3..6127f51 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -439,6 +439,9 @@ virDomainSaveStatus; virDomainSaveXML; virDomainSeclabelTypeFromString; virDomainSeclabelTypeToString; +virDomainShmemFind; +virDomainShmemInsert; +virDomainShmemRemove; virDomainShutdownReasonTypeFromString; virDomainShutdownReasonTypeToString; virDomainShutoffReasonTypeFromString; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 02/10] qemu: always build id when generate shared memory device CLI
When hot-unplug the device, qmp command device_del require a device id. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/qemu/qemu_command.c| 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-shmem.args | 16 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5ac43d8..636e040 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8470,9 +8470,9 @@ qemuBuildShmemDevCmd(virCommandPtr cmd, } if (!shmem-server.enabled) { -virBufferAsprintf(buf, ,shm=%s, shmem-name); +virBufferAsprintf(buf, ,shm=%s,id=%s, shmem-name, shmem-info.alias); } else { -virBufferAsprintf(buf, ,chardev=char%s, shmem-info.alias); +virBufferAsprintf(buf, ,chardev=char%s,id=%s, shmem-info.alias, shmem-info.alias); if (shmem-msi.enabled) { virBufferAddLit(buf, ,msi=on); if (shmem-msi.vectors) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-shmem.args b/tests/qemuxml2argvdata/qemuxml2argv-shmem.args index d37879a..601167c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-shmem.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-shmem.args @@ -1,16 +1,16 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults \ -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \ --device ivshmem,shm=shmem0,bus=pci.0,addr=0x3 \ --device ivshmem,size=128m,shm=shmem1,bus=pci.0,addr=0x4 \ --device ivshmem,size=256m,shm=shmem2,bus=pci.0,addr=0x5 \ --device ivshmem,size=512m,chardev=charshmem3,bus=pci.0,addr=0x6 \ +-device ivshmem,shm=shmem0,id=shmem0,bus=pci.0,addr=0x3 \ +-device ivshmem,size=128m,shm=shmem1,id=shmem1,bus=pci.0,addr=0x4 \ +-device ivshmem,size=256m,shm=shmem2,id=shmem2,bus=pci.0,addr=0x5 \ +-device ivshmem,size=512m,chardev=charshmem3,id=shmem3,bus=pci.0,addr=0x6 \ -chardev socket,id=charshmem3,path=/var/lib/libvirt/shmem-shmem3-sock \ --device ivshmem,size=1024m,chardev=charshmem4,bus=pci.0,addr=0x7 \ +-device ivshmem,size=1024m,chardev=charshmem4,id=shmem4,bus=pci.0,addr=0x7 \ -chardev socket,id=charshmem4,path=/tmp/shmem4-sock \ --device ivshmem,size=2048m,chardev=charshmem5,msi=on,ioeventfd=off,bus=pci.0,addr=0x8 \ +-device ivshmem,size=2048m,chardev=charshmem5,id=shmem5,msi=on,ioeventfd=off,bus=pci.0,addr=0x8 \ -chardev socket,id=charshmem5,path=/tmp/shmem5-sock \ --device ivshmem,size=4096m,chardev=charshmem6,msi=on,vectors=16,bus=pci.0,addr=0x9 \ +-device ivshmem,size=4096m,chardev=charshmem6,id=shmem6,msi=on,vectors=16,bus=pci.0,addr=0x9 \ -chardev socket,id=charshmem6,path=/tmp/shmem6-sock \ --device ivshmem,size=8192m,chardev=charshmem7,msi=on,vectors=32,ioeventfd=on,bus=pci.0,addr=0xa \ +-device ivshmem,size=8192m,chardev=charshmem7,id=shmem7,msi=on,vectors=32,ioeventfd=on,bus=pci.0,addr=0xa \ -chardev socket,id=charshmem7,path=/tmp/shmem7-sock -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 07/10] qemu: Implement shared memory device cold (un)plug
Add support for using the attach/detach device APIs on the inactive configuration to add/del shared memory devices. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 21 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6127f51..aff4e83 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -439,6 +439,7 @@ virDomainSaveStatus; virDomainSaveXML; virDomainSeclabelTypeFromString; virDomainSeclabelTypeToString; +virDomainShmemDefFree; virDomainShmemFind; virDomainShmemInsert; virDomainShmemRemove; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6bb8549..932928f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8160,6 +8160,15 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, dev-data.memory = NULL; break; +case VIR_DOMAIN_DEVICE_SHMEM: +if (virDomainShmemInsert(vmdef, dev-data.shmem) 0) +return -1; +dev-data.shmem = NULL; + +if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) 0) +return -1; +break; + case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: @@ -8169,7 +8178,6 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: -case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: @@ -8296,6 +8304,16 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainMemoryDefFree(virDomainMemoryRemove(vmdef, idx)); break; +case VIR_DOMAIN_DEVICE_SHMEM: +if ((idx = virDomainShmemFind(vmdef, dev-data.shmem)) 0) { +virReportError(VIR_ERR_OPERATION_FAILED, %s, + _(no matching share memory device was found)); +return -1; +} + +virDomainShmemDefFree(virDomainShmemRemove(vmdef, idx)); +break; + case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: @@ -8305,7 +8323,6 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: -case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 01/10] qemu: auto assign pci address for shared memory device
Shared memory device is base on PCI address, even we do not pass the pci address to qemu, qemu will auto assign a pci address for it. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/qemu/qemu_command.c| 11 +++ tests/qemuxml2argvdata/qemuxml2argv-shmem.args | 16 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 89f775d..5ac43d8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2562,6 +2562,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, flags) 0) goto error; } + /* Further non-primary video cards which have to be qxl type */ for (i = 1; i def-nvideos; i++) { if (def-videos[i]-type != VIR_DOMAIN_VIDEO_TYPE_QXL) { @@ -2575,6 +2576,16 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, flags) 0) goto error; } + +/* Shared Memory */ +for (i = 0; i def-nshmems; i++) { +if (def-shmems[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +continue; + +if (virDomainPCIAddressReserveNextSlot(addrs, + def-shmems[i]-info, flags) 0) +goto error; +} for (i = 0; i def-ninputs; i++) { /* Nada - none are PCI based (yet) */ } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-shmem.args b/tests/qemuxml2argvdata/qemuxml2argv-shmem.args index a3d3cc8..d37879a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-shmem.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-shmem.args @@ -1,16 +1,16 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults \ -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \ --device ivshmem,shm=shmem0 \ --device ivshmem,size=128m,shm=shmem1 \ --device ivshmem,size=256m,shm=shmem2 \ --device ivshmem,size=512m,chardev=charshmem3 \ +-device ivshmem,shm=shmem0,bus=pci.0,addr=0x3 \ +-device ivshmem,size=128m,shm=shmem1,bus=pci.0,addr=0x4 \ +-device ivshmem,size=256m,shm=shmem2,bus=pci.0,addr=0x5 \ +-device ivshmem,size=512m,chardev=charshmem3,bus=pci.0,addr=0x6 \ -chardev socket,id=charshmem3,path=/var/lib/libvirt/shmem-shmem3-sock \ --device ivshmem,size=1024m,chardev=charshmem4 \ +-device ivshmem,size=1024m,chardev=charshmem4,bus=pci.0,addr=0x7 \ -chardev socket,id=charshmem4,path=/tmp/shmem4-sock \ --device ivshmem,size=2048m,chardev=charshmem5,msi=on,ioeventfd=off \ +-device ivshmem,size=2048m,chardev=charshmem5,msi=on,ioeventfd=off,bus=pci.0,addr=0x8 \ -chardev socket,id=charshmem5,path=/tmp/shmem5-sock \ --device ivshmem,size=4096m,chardev=charshmem6,msi=on,vectors=16 \ +-device ivshmem,size=4096m,chardev=charshmem6,msi=on,vectors=16,bus=pci.0,addr=0x9 \ -chardev socket,id=charshmem6,path=/tmp/shmem6-sock \ --device ivshmem,size=8192m,chardev=charshmem7,msi=on,vectors=32,ioeventfd=on \ +-device ivshmem,size=8192m,chardev=charshmem7,msi=on,vectors=32,ioeventfd=on,bus=pci.0,addr=0xa \ -chardev socket,id=charshmem7,path=/tmp/shmem7-sock -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 03/10] qemu: Refactor creation of shared memory device commandline
Rename qemuBuildShmemDevCmd to qemuBuildShmemDevStr and change the return type so that it can be reused in the device hotplug code later. And split the chardev creation part in a new function qemuBuildShmemBackendStr for reused in the device hotplug code later. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/qemu/qemu_command.c | 70 +++-- src/qemu/qemu_command.h | 7 + 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 636e040..0414f77 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8433,9 +8433,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, return ret; } -static int -qemuBuildShmemDevCmd(virCommandPtr cmd, - virDomainDefPtr def, +char * +qemuBuildShmemDevStr(virDomainDefPtr def, virDomainShmemDefPtr shmem, virQEMUCapsPtr qemuCaps) { @@ -8489,14 +8488,38 @@ qemuBuildShmemDevCmd(virCommandPtr cmd, if (virBufferCheckError(buf) 0) goto error; -virCommandAddArg(cmd, -device); -virCommandAddArgBuffer(cmd, buf); - -return 0; +return virBufferContentAndReset(buf); error: virBufferFreeAndReset(buf); -return -1; +return NULL; +} + +char * +qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem, + virQEMUCapsPtr qemuCaps) +{ +char *devstr = NULL; +virDomainChrSourceDef source = { +.type = VIR_DOMAIN_CHR_TYPE_UNIX, +.data.nix = { +.path = shmem-server.path, +.listen = false, +} +}; + +if (!shmem-server.path +virAsprintf(source.data.nix.path, +/var/lib/libvirt/shmem-%s-sock, +shmem-name) 0) +return NULL; + +devstr = qemuBuildChrChardevStr(source, shmem-info.alias, qemuCaps); + +if (!shmem-server.path) +VIR_FREE(source.data.nix.path); + +return devstr; } static int @@ -8505,35 +8528,18 @@ qemuBuildShmemCommandLine(virCommandPtr cmd, virDomainShmemDefPtr shmem, virQEMUCapsPtr qemuCaps) { -if (qemuBuildShmemDevCmd(cmd, def, shmem, qemuCaps) 0) +char *devstr = NULL; + +if (!(devstr = qemuBuildShmemDevStr(def, shmem, qemuCaps))) return -1; +virCommandAddArgList(cmd, -device, devstr, NULL); +VIR_FREE(devstr); if (shmem-server.enabled) { -char *devstr = NULL; -virDomainChrSourceDef source = { -.type = VIR_DOMAIN_CHR_TYPE_UNIX, -.data.nix = { -.path = shmem-server.path, -.listen = false, -} -}; - -if (!shmem-server.path -virAsprintf(source.data.nix.path, -/var/lib/libvirt/shmem-%s-sock, -shmem-name) 0) +if (!(devstr = qemuBuildShmemBackendStr(shmem, qemuCaps))) return -1; -devstr = qemuBuildChrChardevStr(source, shmem-info.alias, qemuCaps); - -if (!shmem-server.path) -VIR_FREE(source.data.nix.path); - -if (!devstr) -return -1; - -virCommandAddArg(cmd, -chardev); -virCommandAddArg(cmd, devstr); +virCommandAddArgList(cmd, -chardev, devstr, NULL); VIR_FREE(devstr); } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 0fc59a8..73f24dc 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -194,6 +194,13 @@ int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng, const char **type, virJSONValuePtr *props); +char *qemuBuildShmemDevStr(virDomainDefPtr def, + virDomainShmemDefPtr shmem, + virQEMUCapsPtr qemuCaps); +char *qemuBuildShmemBackendStr(virDomainShmemDefPtr shmem, + virQEMUCapsPtr qemuCaps); + + int qemuOpenPCIConfig(virDomainHostdevDefPtr dev); /* Legacy, pre device support */ -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 08/10] qemu: Implement share memory device hot-plug
Signed-off-by: Luyao Huang lhu...@redhat.com --- src/qemu/qemu_driver.c | 10 - src/qemu/qemu_hotplug.c | 60 + src/qemu/qemu_hotplug.h | 3 +++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 932928f..b5a0be0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7789,6 +7789,15 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, dev-data.memory = NULL; break; +case VIR_DOMAIN_DEVICE_SHMEM: +ret = qemuDomainAttachShmemDevice(driver, vm, + dev-data.shmem); +if (!ret) { +alias = dev-data.shmem-info.alias; +dev-data.shmem = NULL; +} +break; + case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -7800,7 +7809,6 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: -case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index cc86a3b..188807e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1832,6 +1832,66 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, } +int +qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, +virDomainObjPtr vm, +virDomainShmemDefPtr shmem) +{ +int ret = -1; +qemuDomainObjPrivatePtr priv = vm-privateData; +char *devstr = NULL; +char *charAlias = NULL; + +if (virAsprintf(shmem-info.alias, shmem%zu, vm-def-nshmems) 0) +return -1; + +if (VIR_REALLOC_N(vm-def-shmems, vm-def-nshmems + 1) 0) +return -1; + +if ((shmem-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || + shmem-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + (virDomainPCIAddressEnsureAddr(priv-pciaddrs, shmem-info) 0)) +return -1; + +if (!(devstr = qemuBuildShmemDevStr(vm-def, shmem, priv-qemuCaps))) +goto cleanup; + +if (virAsprintf(charAlias, char%s, shmem-info.alias) 0) +goto cleanup; + +qemuDomainObjEnterMonitor(driver, vm); + +if (shmem-server.enabled +qemuMonitorAttachCharDev(priv-mon, charAlias, + shmem-server.chr) 0) { +ignore_value(qemuDomainObjExitMonitor(driver, vm)); +goto audit; +} + +if (qemuMonitorAddDevice(priv-mon, devstr) 0) { +if (shmem-server.enabled) +ignore_value(qemuMonitorDetachCharDev(priv-mon, charAlias)); +ignore_value(qemuDomainObjExitMonitor(driver, vm)); +goto audit; +} +if (qemuDomainObjExitMonitor(driver, vm) 0) +goto audit; + +if (virDomainShmemInsert(vm-def, shmem) 0) +goto audit; + +ret = 0; + audit: +virDomainAuditShmem(vm, NULL, shmem, attach, ret == 0); + cleanup: +if (ret 0) +qemuDomainReleaseDeviceAddress(vm, shmem-info, NULL); +VIR_FREE(charAlias); +VIR_FREE(devstr); +return ret; +} + + static int qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 4140da3..60137a6 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -109,6 +109,9 @@ int qemuDomainAttachRNGDevice(virQEMUDriverPtr driver, int qemuDomainDetachRNGDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainRNGDefPtr rng); +int qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, +virDomainObjPtr vm, +virDomainShmemDefPtr shmem); int qemuDomainChrInsert(virDomainDefPtr vmdef, -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 05/10] conf:audit: introduce audit function for shared memory device
Signed-off-by: Luyao Huang lhu...@redhat.com --- docs/auditlog.html.in| 16 src/conf/domain_audit.c | 16 src/conf/domain_audit.h | 6 ++ src/libvirt_private.syms | 1 + 4 files changed, 39 insertions(+) diff --git a/docs/auditlog.html.in b/docs/auditlog.html.in index 8a007ca..b168cbf 100644 --- a/docs/auditlog.html.in +++ b/docs/auditlog.html.in @@ -301,6 +301,22 @@ ddUpdated path of the backing character device for given emulated device/dd /dl +h4a name=typeresourceivshmemShared memory device/a/h4 +p + The codemsg/code field will include the following sub-fields +/p + +dl + dtreason/dt + ddThe reason which caused the resource to be assigned to happen/dd + dtresrc/dt + ddThe type of resource assigned. Set to codeshmem/code/dd + dtold-shmem/dt + ddOriginal memory size of share memory device in bytes, or 0/dd + dtnew-shmem/dt + ddUpdated memory size of share memory device in bytes/dd +/dl + h4a name=typeresourcesmartcardsmartcard/a/h4 p The codemsg/code field will include the following sub-fields diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 1900039..aa2b4b5 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -799,6 +799,19 @@ virDomainAuditIOThread(virDomainObjPtr vm, reason, success); } + +void +virDomainAuditShmem(virDomainObjPtr vm, +virDomainShmemDefPtr oldDef, virDomainShmemDefPtr newDef, +const char *reason, bool success) +{ +return virDomainAuditResource(vm, shmem, + oldDef ? oldDef-size : 0, + newDef ? newDef-size : 0, + reason, success); +} + + static void virDomainAuditLifecycle(virDomainObjPtr vm, const char *op, const char *reason, bool success) @@ -880,6 +893,9 @@ virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success) for (i = 0; i vm-def-nrngs; i++) virDomainAuditRNG(vm, NULL, vm-def-rngs[i], start, true); +for (i = 0; i vm-def-nshmems; i++) +virDomainAuditShmem(vm, NULL, vm-def-shmems[i], start, true); + if (vm-def-tpm) virDomainAuditTPM(vm, vm-def-tpm, start, true); diff --git a/src/conf/domain_audit.h b/src/conf/domain_audit.h index 97dadca..081cbb1 100644 --- a/src/conf/domain_audit.h +++ b/src/conf/domain_audit.h @@ -129,6 +129,12 @@ void virDomainAuditRNG(virDomainObjPtr vm, const char *reason, bool success) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); +void virDomainAuditShmem(virDomainObjPtr vm, + virDomainShmemDefPtr oldDef, + virDomainShmemDefPtr newDef, + const char *reason, + bool success) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); #endif /* __VIR_DOMAIN_AUDIT_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index dc8a52d..3ceb4e3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -134,6 +134,7 @@ virDomainAuditNetDevice; virDomainAuditRedirdev; virDomainAuditRNG; virDomainAuditSecurityLabel; +virDomainAuditShmem; virDomainAuditStart; virDomainAuditStop; virDomainAuditVcpu; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 10/10] qemu: report error when shmem have a invalid address
If user pass a invalid address shared memory device to qemu, qemu won't report the error, but will auto assign a pci address to the shared memory device. Signed-off-by: Luyao Huang lhu...@redhat.com --- src/qemu/qemu_command.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5d55794..9c659fe 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8482,6 +8482,13 @@ qemuBuildShmemDevStr(virDomainDefPtr def, } } +if (shmem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(only 'pci' addresses are supported for the + shared memory device)); +goto error; +} + if (qemuBuildDeviceAddressStr(buf, def, shmem-info, qemuCaps) 0) goto error; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 00/10] Implement shared memory device - Part 1
This part contains some small fix and Implement the hot-plug/hot-unplug and cold-plug/cold-unplug for Inter-VM Shared Memory PCI device. Luyao Huang (10): qemu: auto assign pci address for shared memory device qemu: always build id when generate shared memory device CLI qemu: Refactor creation of shared memory device commandline conf: use virDomainChrSourceDef to save the path conf:audit: introduce audit function for shared memory device conf: Add helpers to insert/remove/find shmem devices in domain def qemu: Implement shared memory device cold (un)plug qemu: Implement share memory device hot-plug qemu: Implement shared memory device hot-unplug qemu: report error when shmem have a invalid address docs/auditlog.html.in | 16 +++ src/conf/domain_audit.c| 16 +++ src/conf/domain_audit.h| 6 + src/conf/domain_conf.c | 69 ++- src/conf/domain_conf.h | 9 +- src/libvirt_private.syms | 5 + src/qemu/qemu_command.c| 82 +++-- src/qemu/qemu_command.h| 7 ++ src/qemu/qemu_driver.c | 35 +- src/qemu/qemu_hotplug.c| 156 - src/qemu/qemu_hotplug.h| 6 + tests/qemuxml2argvdata/qemuxml2argv-shmem.args | 16 +-- 12 files changed, 372 insertions(+), 51 deletions(-) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCHv2 1/8] threshold: new API virDomainBlockSetWriteThreshold
- Original Message - From: Eric Blake ebl...@redhat.com To: Peter Krempa pkre...@redhat.com Cc: libvir-list@redhat.com, from...@redhat.com Sent: Monday, June 15, 2015 6:21:13 PM Subject: Re: [libvirt] [RFC PATCHv2 1/8] threshold: new API virDomainBlockSetWriteThreshold On 06/15/2015 07:19 AM, Peter Krempa wrote: On Fri, Jun 12, 2015 at 13:29:25 -0600, Eric Blake wrote: qemu 2.3 added a new QMP command block-set-write-threshold, which allows callers to get an interrupt when a file hits a write threshold, rather than the current approach of repeatedly polling for file allocation. This patch prepares the API for callers to register to receive the event, as well as a way to query the threshold via virDomainListGetStats(). + +typedef enum { +/* threshold is thousandth of a percentage (0 to 10) relative to You managed to choose a unusual unit. Commonly used ones are 1/1000 and 1/1 000 000. Financial world also uses 1/10 000. Your unit of 1/100 000 is not among: https://en.wikipedia.org/wiki/Parts-per_notation#Parts-per_expressions I'd again suggest to use 1/1 000 000. Or if you want to be uber preciese you might choose 1/(2^64 - 1). Francesco, what precision would you like? Parts per million seems okay to me, if we want an order of magnitude closer; and I don't think we need anything beyond that. Or if parts per thousand is sufficient, that leads to smaller numbers on input. But it's pretty trivial for me to adjust the code to a different base, for whatever people would like. We (in oVirt) use very coarse thresholds. For our current needs, I believe even parts per thousand is sufficient. Trying to be a bit forward thinking, I believe parts per million is perfectly fine. Bests, -- Francesco Romani RedHat Engineering Virtualization R D Phone: 8261328 IRC: fromani -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/3] storage: Fix the schema and add tests for cifs pool
On Mon, Jun 15, 2015 at 17:30:35 -0400, John Ferlan wrote: Commit id '887dd362' added support for a netfs pool format type 'cifs' and 'gluster' in order to add rng support for Samba and glusterfs netfs pools. Originally, the CIFS type support was added as part of commit id '61fb6979'. Eventually commit id 'b325be12' fixed the gluster rng definition to match expectations. As it turns out the CIFS rng needed a similar change since the directory path is not an absDirPath, rather just a dirPath will be required. Signed-off-by: John Ferlan jfer...@redhat.com --- docs/schemas/storagepool.rng| 10 ++ tests/storagepoolxml2xmlin/pool-netfs-cifs.xml | 12 tests/storagepoolxml2xmlout/pool-netfs-cifs.xml | 15 +++ tests/storagepoolxml2xmltest.c | 1 + 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-cifs.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-cifs.xml ACK, Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/3] storage: Generate correct parameters for CIFS
On Mon, Jun 15, 2015 at 17:30:37 -0400, John Ferlan wrote: https://bugzilla.redhat.com/show_bug.cgi?id=1186969 When generating the path to the dir for a CIFS/Samba driver, the code would generate a source path for the mount using %s:%s while the mount.cifs expects to see //%s/%s. So check for the cifsfs and format the source path appropriately. Additionally, since there is no means to authenticate, the mount needs a -o guest on the command line in order to anonymously mount the Samba directory. Signed-off-by: John Ferlan jfer...@redhat.com --- docs/formatstorage.html.in | 7 +-- docs/storage.html.in | 3 ++- src/storage/storage_backend_fs.c | 27 ++- 3 files changed, 29 insertions(+), 8 deletions(-) ACK, Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/3] storage: Adjust command arglist for gluster
On Mon, Jun 15, 2015 at 17:30:36 -0400, John Ferlan wrote: In order for the glusterfs boolean to be set, the pool-def-type must be VIR_STORAGE_POOL_NETFS, thus the check within virCommandNewArgList whether pool-def-type is VIR_STORAGE_POOL_FS will never be true, so remove it Signed-off-by: John Ferlan jfer...@redhat.com --- src/storage/storage_backend_fs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) ACK, Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Publishing a Python libvirt Howto/Reference Guide
On 15.06.2015 17:48, David Ashley wrote: All - I represent the Fedora Docs Team. We are interested in publishing a Python libvirt HowTo/Reference Guide for users. We feel that there is a gap with using virtualization from a scripting environment. While virsh fills this gap for simple scripting purposes, a more powerful scripting language is needed for deep administrative purposes. Python is the obvious choice and the libvirt team has provided a great Python module. What is really missing are examples of using the module in both simple and deeper tasks i.e. something more than just how to start and stop a domain. We propose to create such a document. While we can use pydoc to create the reference material, we need some really good examples that can teach a user how to get real work done using the classes. We also propose to share the document with the libvirt team taking either an upstream or downstream role in maintaining the document. The document would be written in DocBook and published using the Publican system. This would allow you to create your own brand for the document (look and feel) while maintaining compatible source for both our teams. It would also allow the source to be maintained by both teams. If this sounds interesting to you we would like to begin our planning for the document in the near future with one or more representatives from the libvirt team on board. Please let either myself or Laura Novich (cc'ed on this email) know if this proposal meets with your approval. I appreciate any kind of documentation work. If sent, I'll review the patches too. Also, there's examples/ folder which contains I'd say small and medium examples: http://libvirt.org/git/?p=libvirt-python.git;a=tree;f=examples;h=16c5795a3d6f7d5deb7cdf8ab27fb3f958e3f963;hb=HEAD Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 0/4] Filesystem config improvements
Hi all, Here is the previous patch split into a series. The difference with v1 are: * it adds test-gconfig test for file systems * the gvir_config_domain_filesys_set_driver_type fix has been moved to its own commit * the gvir_config_domain_filesys_set_driver_format doesn't set the type, the user just has to make sure he doesn't do stupid things * a test for the new function has been added to test-gconfig Cédric Bosdonnat (4): test-gconfig: add filesystem test gvir_config_domain_filesys_set_driver_type: replace the driver node Add loop and nbd filesystem types domain config: add API to set the filesystem image format libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 18 +++- libvirt-gconfig/libvirt-gconfig-domain-filesys.h | 4 +++ libvirt-gconfig/libvirt-gconfig.sym | 5 tests/test-gconfig.c | 36 tests/xml/gconfig-domain-device-filesys.xml | 15 ++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/xml/gconfig-domain-device-filesys.xml -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 3/4] Add loop and nbd filesystem types
--- libvirt-gconfig/libvirt-gconfig-domain-filesys.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h index 4f3973e..4144976 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h @@ -75,6 +75,8 @@ typedef enum { GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_PATH, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_HANDLE, +GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_LOOP, +GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD, } GVirConfigDomainFilesysDriverType; GType gvir_config_domain_filesys_get_type(void); -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 1/4] test-gconfig: add filesystem test
--- tests/test-gconfig.c| 35 + tests/xml/gconfig-domain-device-filesys.xml | 15 + 2 files changed, 50 insertions(+) create mode 100644 tests/xml/gconfig-domain-device-filesys.xml diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index bd75008..e7dafde 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -358,6 +358,39 @@ static void test_domain_device_disk(void) } +static void test_domain_device_filesystem(void) +{ +GVirConfigDomain *domain; +GVirConfigDomainFilesys *fs; + +domain = gvir_config_domain_new(); + +fs = gvir_config_domain_filesys_new(); +gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_FILE); +gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_MAPPED); +gvir_config_domain_filesys_set_driver_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT); +gvir_config_domain_filesys_set_source(fs, /path/to/source); +gvir_config_domain_filesys_set_target(fs, /path/to/target1); +gvir_config_domain_filesys_set_readonly(fs, TRUE); +gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(fs)); +g_object_unref(fs); + +/* Add a RAM fs */ +fs = gvir_config_domain_filesys_new(); +gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_RAM); +gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_PASSTHROUGH); +gvir_config_domain_filesys_set_driver_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_PATH); +gvir_config_domain_filesys_set_ram_usage(fs, 1234); +gvir_config_domain_filesys_set_target(fs, /path/to/target2); +gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(fs)); +g_object_unref(fs); + +check_xml(domain, gconfig-domain-device-filesys.xml); + +g_object_unref(G_OBJECT(domain)); +} + + static void test_domain_device_network(void) { GVirConfigDomain *domain; @@ -665,6 +698,8 @@ int main(int argc, char **argv) g_test_add_func(/libvirt-gconfig/domain-cpu, test_domain_cpu); g_test_add_func(/libvirt-gconfig/domain-device-disk, test_domain_device_disk); +g_test_add_func(/libvirt-gconfig/domain-device-filesystem, +test_domain_device_filesystem); g_test_add_func(/libvirt-gconfig/domain-device-network, test_domain_device_network); g_test_add_func(/libvirt-gconfig/domain-device-input, diff --git a/tests/xml/gconfig-domain-device-filesys.xml b/tests/xml/gconfig-domain-device-filesys.xml new file mode 100644 index 000..5db6d61 --- /dev/null +++ b/tests/xml/gconfig-domain-device-filesys.xml @@ -0,0 +1,15 @@ +domain + devices +filesystem type=file accessmode=mapped + driver/ + source file=/path/to/source/ + target dir=/path/to/target1/ + readonly/ +/filesystem +filesystem type=ram accessmode=passthrough + driver type=path/ + source usage=1234 units=bytes/ + target dir=/path/to/target2/ +/filesystem + /devices +/domain -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 4/4] domain config: add API to set the filesystem image format
Add the gvir_config_domain_filesys_set_driver_format function to allow setting nbd driver type + image format for containers filesystems. --- libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 16 libvirt-gconfig/libvirt-gconfig-domain-filesys.h | 2 ++ libvirt-gconfig/libvirt-gconfig.sym | 5 + tests/test-gconfig.c | 1 + tests/xml/gconfig-domain-device-filesys.xml | 2 +- 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c index dc49bcd..9b73af5 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c @@ -137,6 +137,22 @@ void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys g_object_unref(G_OBJECT(node)); } +void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *filesys, + GVirConfigDomainDiskFormat format) +{ +GVirConfigObject *node; + +g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys)); +node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); +g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node)); + +gvir_config_object_set_attribute_with_type( +node, +format, GVIR_CONFIG_TYPE_DOMAIN_DISK_FORMAT, format, +NULL); +g_object_unref(G_OBJECT(node)); +} + void gvir_config_domain_filesys_set_source(GVirConfigDomainFilesys *filesys, const char *source) { diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h index 4144976..18c4069 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.h @@ -91,6 +91,8 @@ void gvir_config_domain_filesys_set_access_type(GVirConfigDomainFilesys *filesys GVirConfigDomainFilesysAccessType type); void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys, GVirConfigDomainFilesysDriverType type); +void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *filesys, + GVirConfigDomainDiskFormat format); void gvir_config_domain_filesys_set_source(GVirConfigDomainFilesys *filesys, const char *source); void gvir_config_domain_filesys_set_ram_usage(GVirConfigDomainFilesys *filesys, diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 407a52f..6ce1511 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -719,4 +719,9 @@ global: gvir_config_storage_vol_target_set_compat; } LIBVIRT_GCONFIG_0.1.9; +LIBVIRT_GCONFIG_0.2.1 { +global: +gvir_config_domain_filesys_set_driver_format; +} LIBVIRT_GCONFIG_0.2.0; + # define new API here using predicted next version number diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index e7dafde..bd2daa6 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -369,6 +369,7 @@ static void test_domain_device_filesystem(void) gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_FILE); gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_MAPPED); gvir_config_domain_filesys_set_driver_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT); +gvir_config_domain_filesys_set_driver_format(fs, GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2); gvir_config_domain_filesys_set_source(fs, /path/to/source); gvir_config_domain_filesys_set_target(fs, /path/to/target1); gvir_config_domain_filesys_set_readonly(fs, TRUE); diff --git a/tests/xml/gconfig-domain-device-filesys.xml b/tests/xml/gconfig-domain-device-filesys.xml index 5db6d61..30152d2 100644 --- a/tests/xml/gconfig-domain-device-filesys.xml +++ b/tests/xml/gconfig-domain-device-filesys.xml @@ -1,7 +1,7 @@ domain devices filesystem type=file accessmode=mapped - driver/ + driver format=qcow2/ source file=/path/to/source/ target dir=/path/to/target1/ readonly/ -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [sandbox v2 4/4] Add host-image format parameter
Let the user specify the format of the source disk image in host-image mounts. This will allow us to mount other image types than raw ones. --- .../libvirt-sandbox-builder-container.c| 10 +++ libvirt-sandbox/libvirt-sandbox-builder-machine.c | 9 +++ .../libvirt-sandbox-config-mount-host-image.c | 91 +- .../libvirt-sandbox-config-mount-host-image.h | 5 +- libvirt-sandbox/libvirt-sandbox-config.c | 68 +++- libvirt-sandbox/libvirt-sandbox.sym| 5 ++ libvirt-sandbox/tests/test-config.c| 1 + 7 files changed, 181 insertions(+), 8 deletions(-) diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c b/libvirt-sandbox/libvirt-sandbox-builder-container.c index c3a58b2..59bfee1 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-container.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c @@ -273,6 +273,9 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil g_object_unref(fs); } else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_IMAGE(mconfig)) { GVirSandboxConfigMountFile *mfile = GVIR_SANDBOX_CONFIG_MOUNT_FILE(mconfig); +GVirSandboxConfigMountHostImage *mimage = GVIR_SANDBOX_CONFIG_MOUNT_HOST_IMAGE(mconfig); +GVirConfigDomainDiskFormat format; +GVirConfigDomainFilesysDriverType type = GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_LOOP; fs = gvir_config_domain_filesys_new(); gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_FILE); @@ -282,6 +285,13 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil gvir_config_domain_filesys_set_target(fs, gvir_sandbox_config_mount_get_target(mconfig)); +format = gvir_sandbox_config_mount_host_image_get_format(mimage); +if (format != GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW) +type = GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD; + +gvir_config_domain_filesys_set_driver_type(fs, type); +gvir_config_domain_filesys_set_driver_format(fs, format); + gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(fs)); g_object_unref(fs); diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c index e342ba1..5e6bf72 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c @@ -497,6 +497,7 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde { GVirConfigDomainFilesys *fs; GVirConfigDomainDisk *disk; +GVirConfigDomainDiskDriver *diskDriver; GVirConfigDomainInterface *iface; GVirConfigDomainMemballoon *ball; GVirConfigDomainConsole *con; @@ -560,6 +561,8 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde } else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_IMAGE(mconfig)) { GVirSandboxConfigMountFile *mfile = GVIR_SANDBOX_CONFIG_MOUNT_FILE(mconfig); +GVirSandboxConfigMountHostImage *mimage = GVIR_SANDBOX_CONFIG_MOUNT_HOST_IMAGE(mconfig); +GVirConfigDomainDiskFormat format; gchar *target = g_strdup_printf(vd%c, (char)('a' + nHostImage++)); disk = gvir_config_domain_disk_new(); @@ -568,8 +571,14 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde gvir_sandbox_config_mount_file_get_source(mfile)); gvir_config_domain_disk_set_target_dev(disk, target); +diskDriver = gvir_config_domain_disk_driver_new(); +format = gvir_sandbox_config_mount_host_image_get_format(mimage); +gvir_config_domain_disk_driver_set_format(diskDriver, format); +gvir_config_domain_disk_set_driver(disk, diskDriver); + gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(disk)); +g_object_unref(diskDriver); g_object_unref(disk); g_free(target); } diff --git a/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c b/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c index 61e8f42..37573ef 100644 --- a/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c +++ b/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c @@ -45,21 +45,90 @@ struct _GVirSandboxConfigMountHostImagePrivate { -gboolean unused; +GVirConfigDomainDiskFormat format; }; G_DEFINE_TYPE(GVirSandboxConfigMountHostImage, gvir_sandbox_config_mount_host_image, GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE); +enum { +PROP_0, +PROP_FORMAT, +}; + +enum { +LAST_SIGNAL +}; + +//static gint signals[LAST_SIGNAL]; + + +static
[libvirt] [sandbox v2 1/4] Make sure the sandbox state dir and config can be accessed
When running a KVM sandbox as root, the qemu process will run as another user (likely qemu). We need to make sure this user can access the vmlinux and initrd.img, sandbox.cfg and mounts.cfg files. --- libvirt-sandbox/libvirt-sandbox-config.c | 2 +- libvirt-sandbox/libvirt-sandbox-context-interactive.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libvirt-sandbox/libvirt-sandbox-config.c b/libvirt-sandbox/libvirt-sandbox-config.c index 087b5ce..8991043 100644 --- a/libvirt-sandbox/libvirt-sandbox-config.c +++ b/libvirt-sandbox/libvirt-sandbox-config.c @@ -2258,7 +2258,7 @@ gboolean gvir_sandbox_config_save_to_path(GVirSandboxConfig *config, if (!(data = g_key_file_to_data(file, len, error))) goto cleanup; -if (!(os = G_OUTPUT_STREAM(g_file_create(f, G_FILE_CREATE_PRIVATE, NULL, error +if (!(os = G_OUTPUT_STREAM(g_file_create(f, G_FILE_CREATE_NONE, NULL, error goto cleanup; if (!g_output_stream_write_all(os, data, len, NULL, NULL, error)) diff --git a/libvirt-sandbox/libvirt-sandbox-context-interactive.c b/libvirt-sandbox/libvirt-sandbox-context-interactive.c index cec7965..78b2fbd 100644 --- a/libvirt-sandbox/libvirt-sandbox-context-interactive.c +++ b/libvirt-sandbox/libvirt-sandbox-context-interactive.c @@ -217,8 +217,8 @@ static gboolean gvir_sandbox_context_interactive_start(GVirSandboxContext *ctxt, error))) goto cleanup; -g_mkdir_with_parents(statedir, 0700); -g_mkdir_with_parents(configdir, 0700); +g_mkdir_with_parents(statedir, 0755); +g_mkdir_with_parents(configdir, 0755); unlink(configfile); if (!gvir_sandbox_config_save_to_path(config, configfile, error)) -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Publishing a Python libvirt Howto/Reference Guide
On Mon, Jun 15, 2015 at 10:48:29AM -0500, David Ashley wrote: All - I represent the Fedora Docs Team. We are interested in publishing a Python libvirt HowTo/Reference Guide for users. We feel that there is a gap with using virtualization from a scripting environment. While virsh fills this gap for simple scripting purposes, a more powerful scripting language is needed for deep administrative purposes. Python is the obvious choice and the libvirt team has provided a great Python module. What is really missing are examples of using the module in both simple and deeper tasks i.e. something more than just how to start and stop a domain. We propose to create such a document. While we can use pydoc to create the reference material, we need some really good examples that can teach a user how to get real work done using the classes. We also propose to share the document with the libvirt team taking either an upstream or downstream role in maintaining the document. The document would be written in DocBook and published using the Publican system. This would allow you to create your own brand for the document (look and feel) while maintaining compatible source for both our teams. It would also allow the source to be maintained by both teams. If this sounds interesting to you we would like to begin our planning for the document in the near future with one or more representatives from the libvirt team on board. Please let either myself or Laura Novich (cc'ed on this email) know if this proposal meets with your approval. A few years back now, we did start creating a libvirt application development guide in docbook but the person working on it then switched jobs so it never got very far http://libvirt.org/git/?p=libvirt-appdev-guide.git;a=summary The bulk of the guide was going to focus on explaining the general libvirt concepts for different scenarios, and where code was needed, simple C code snippets inlined. We did, however, wish to have a chapter on usage of each of the language bindings too, which would included python obviously. So if you create any content related to use of the python bindings, it'd be desirable to import it into that document in some manner. We had a publican theme for the doc, but I wouldn't be surprised if it has bitrotted since we created it. http://libvirt.org/git/?p=libvirt-publican.git;a=summary Regards, 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 v2 0/2] lxc: properly clean up qemu-nbd
On Thu, Jun 11, 2015 at 03:04:33PM +0100, Daniel P. Berrange wrote: On Wed, Jun 10, 2015 at 04:08:41PM -0400, John Ferlan wrote: On 06/01/2015 09:01 AM, Cédric Bosdonnat wrote: Hi all, Here is the very same patch, but split in two patches. Well, I also moved two comments around between v1 and v2. Cédric Bosdonnat (2): Add virProcessGetPids to get all tasks of a process lxc: properly clean up qemu-nbd src/libvirt_private.syms | 1 + src/lxc/lxc_controller.c | 56 src/util/virprocess.c| 47 src/util/virprocess.h| 2 ++ 4 files changed, 106 insertions(+) Never saw the 1/2 and 2/2 show up in my inbox and I don't see them in the archive - just your 0/2. Same here - I only received the cover letter it appears So this patches appear to have gone into a black hole. Could you just repost this series again so we can review it Regards, 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
[libvirt] [sandbox v2 0/4] Getting qemu sandboxes run as root + host-image format
Hi all, Here are a few patches to make sandboxes run with qemu:///system connection. The last one is just a new feature to allow using somethings else than RAW images in host-image mounts. This feature will later be needed to run docker container using Eren's work. Diff to v1: * Adapted the code to set the filesystem type due to the changes in libvirt-glib patch (v2). Cédric Bosdonnat (4): Make sure the sandbox state dir and config can be accessed Write /dev/vd* instead of vd* in mounts.cfg qemu: mount all host-images as ext4 Add host-image format parameter .../libvirt-sandbox-builder-container.c| 10 +++ libvirt-sandbox/libvirt-sandbox-builder-machine.c | 13 +++- .../libvirt-sandbox-config-mount-host-image.c | 91 +- .../libvirt-sandbox-config-mount-host-image.h | 5 +- libvirt-sandbox/libvirt-sandbox-config.c | 70 +++-- .../libvirt-sandbox-context-interactive.c | 4 +- libvirt-sandbox/libvirt-sandbox.sym| 5 ++ libvirt-sandbox/tests/test-config.c| 1 + 8 files changed, 186 insertions(+), 13 deletions(-) -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [sandbox v2 3/4] qemu: mount all host-images as ext4
To avoid troubles when mounting ext4 images, hard-code ext4 as mount format instead of ext3. --- libvirt-sandbox/libvirt-sandbox-builder-machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c index c446447..e342ba1 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c @@ -304,7 +304,7 @@ static gboolean gvir_sandbox_builder_machine_write_mount_cfg(GVirSandboxConfig * options = g_strdup(trans=virtio,version=9p2000.u); } else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_IMAGE(mconfig)) { source = g_strdup_printf(/dev/vd%c, (char)('a' + nHostImage++)); -fstype = ext3; +fstype = ext4; options = g_strdup(); } else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_GUEST_BIND(mconfig)) { GVirSandboxConfigMountFile *mfile = GVIR_SANDBOX_CONFIG_MOUNT_FILE(mconfig); -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 2/2] lxc: properly clean up qemu-nbd
Add the qemu-nbd tasks to the container cgroup to make sure those will be killed when the container is stopped. In order to reliably get the qemu-nbd tasks PIDs, we use /sys/devices/virtual/block/DEV/pid as qemu-nbd is daemonizing itself. --- src/lxc/lxc_controller.c | 56 1 file changed, 56 insertions(+) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index efbe71f..9b6f0c8 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -107,6 +107,9 @@ struct _virLXCController { pid_t initpid; +size_t nnbdpids; +pid_t *nbdpids; + size_t nveths; char **veths; @@ -283,6 +286,8 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl) virObjectUnref(ctrl-server); virLXCControllerFreeFuse(ctrl); +VIR_FREE(ctrl-nbdpids); + virCgroupFree(ctrl-cgroup); /* This must always be the last thing to be closed */ @@ -525,6 +530,38 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr disk) return 0; } +static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl, + const char *dev) +{ +char *pidpath = NULL; +pid_t *pids; +size_t npids; +size_t i; +int ret = -1; +pid_t pid; + +if (!STRPREFIX(dev, /dev/) || +virAsprintf(pidpath, /sys/devices/virtual/block/%s/pid, dev + 5) 0) +goto cleanup; + +if (virPidFileReadPath(pidpath, pid) 0) +goto cleanup; + +if (virProcessGetPids(pid, npids, pids) 0) +goto cleanup; + +for (i = 0; i npids; i++) { +if (VIR_APPEND_ELEMENT(ctrl-nbdpids, ctrl-nnbdpids, pids[i]) 0) +goto cleanup; +} + +ret = 0; + + cleanup: +VIR_FREE(pids); +VIR_FREE(pidpath); +return ret; +} static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) { @@ -570,6 +607,12 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) } else if (fs-fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_NBD) { if (virLXCControllerSetupNBDDeviceFS(fs) 0) goto cleanup; + +/* The NBD device will be cleaned up while the cgroup will end. + * For this we need to remember the qemu-nbd pid and add it to + * the cgroup*/ +if (virLXCControllerAppendNBDPids(ctrl, fs-src) 0) +goto cleanup; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(fs driver %s is not supported), @@ -629,6 +672,12 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) } if (virLXCControllerSetupNBDDeviceDisk(disk) 0) goto cleanup; + +/* The NBD device will be cleaned up while the cgroup will end. + * For this we need to remember the qemu-nbd pid and add it to + * the cgroup*/ +if (virLXCControllerAppendNBDPids(ctrl, virDomainDiskGetSource(disk)) 0) +goto cleanup; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(disk driver %s is not supported), @@ -781,6 +830,7 @@ static int virLXCControllerSetupCgroupLimits(virLXCControllerPtr ctrl) virBitmapPtr auto_nodeset = NULL; int ret = -1; virBitmapPtr nodeset = NULL; +size_t i; VIR_DEBUG(Setting up cgroup resource limits); @@ -798,6 +848,12 @@ static int virLXCControllerSetupCgroupLimits(virLXCControllerPtr ctrl) if (virCgroupAddTask(ctrl-cgroup, getpid()) 0) goto cleanup; +/* Add all qemu-nbd tasks to the cgroup */ +for (i = 0; i ctrl-nnbdpids; i++) { +if (virCgroupAddTask(ctrl-cgroup, ctrl-nbdpids[i]) 0) +goto cleanup; +} + if (virLXCCgroupSetup(ctrl-def, ctrl-cgroup, nodeset) 0) goto cleanup; -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/2] Add virProcessGetPids to get all tasks of a process
This function gets all the PIDs listed in /proc/PID/task. This will be needed at least to move all qmeu-nbd tasks to the container cgroup. --- src/libvirt_private.syms | 1 + src/util/virprocess.c| 47 +++ src/util/virprocess.h| 2 ++ 3 files changed, 50 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6a95fb9..780cfbb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1986,6 +1986,7 @@ virProcessAbort; virProcessExitWithStatus; virProcessGetAffinity; virProcessGetNamespaces; +virProcessGetPids; virProcessGetStartTime; virProcessKill; virProcessKillPainfully; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 7a79970..ce5e106 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -608,6 +608,53 @@ int virProcessGetAffinity(pid_t pid ATTRIBUTE_UNUSED, #endif /* HAVE_SCHED_GETAFFINITY */ +int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) +{ +int ret = -1; +char *taskPath = NULL; +DIR *dir = NULL; +int value; +struct dirent *ent; + +*npids = 0; +*pids = NULL; + +if (virAsprintf(taskPath, /proc/%llu/task, +(unsigned long long)pid) 0) +goto cleanup; + +if (!(dir = opendir(taskPath))) +goto cleanup; + +while ((value = virDirRead(dir, ent, taskPath)) 0) { +pid_t tmp_pid; + +/* Skip . and .. */ +if (STRPREFIX(ent-d_name, .)) +continue; + +if (virStrToLong_i(ent-d_name, NULL, 10, tmp_pid) 0) +goto cleanup; + +if (VIR_APPEND_ELEMENT(*pids, *npids, tmp_pid) 0) +goto cleanup; +} + +if (value 0) +goto cleanup; + +ret = 0; + + cleanup: +if (!dir) +closedir(dir); +VIR_FREE(taskPath); +if (ret 0) +VIR_FREE(*pids); +return ret; +} + + int virProcessGetNamespaces(pid_t pid, size_t *nfdlist, int **fdlist) diff --git a/src/util/virprocess.h b/src/util/virprocess.h index c812882..86a633d 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -62,6 +62,8 @@ int virProcessGetAffinity(pid_t pid, virBitmapPtr *map, int maxcpu); +int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids); + int virProcessGetStartTime(pid_t pid, unsigned long long *timestamp); -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 0/2] lxc: properly clean up qemu-nbd (resent)
Just resending the initial patch series as it went into a black hole. Hi all, Here is the very same patch, but split in two patches. Well, I also moved two comments around between v1 and v2. Cédric Bosdonnat (2): Add virProcessGetPids to get all tasks of a process lxc: properly clean up qemu-nbd src/libvirt_private.syms | 1 + src/lxc/lxc_controller.c | 56 src/util/virprocess.c| 47 src/util/virprocess.h| 2 ++ 4 files changed, 106 insertions(+) -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] Add libvirt-admin library
On Tue, Jun 16, 2015 at 11:58:24AM +0200, Martin Kletzander wrote: Initial scratch of the admin library. It has its own virAdmConnectPtr that inherits from virAbstractConnectPtr and thus trivially supports error reporting. There's pkg-config file added and spec-file adjusted as well. Since the library should be minimalistic and not depend on any other library, the list of files is especially crafted for it. Most of them could've been put to it's own sub-libraries that would be LIBADD'd to libvirt_util, libvirt_net_rpc and libvirt_setuid_rpc_client to minimize the number of object files being built, but that's a refactoring that isn't the orginal aim of this commit. Signed-off-by: Martin Kletzander mklet...@redhat.com +/** + * virAdmInitialize: + * + * Initialize the library. + * + * Returns 0 in case of success, -1 in case of error + */ +static int +virAdmInitialize(void) +{ +if (virOnce(virAdmGlobalOnce, virAdmGlobalInit) 0) +return -1; + +if (virAdmGlobalError) +return -1; + +return 0; +} This is declared static +LIBVIRT_ADMIN_1.3.0 { +global: +virAdmInitialize; +virAdmConnectOpen; +virAdmConnectClose; +virAdmConnectRef; So does not need to be listed here ACK with that removed Regards, 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
[libvirt] [PATCH] qemu: add value range check of option granularity
The default value of the granularity is the image cluster size clamped between 4096 and 65536. Libvirt should add a check for this otherwise qemu will report error like below: $ virsh blockcopy r7 vda /var/lib/libvirt/images/r7.s1 --granularity 32 error: internal error: unable to execute QEMU command 'drive-mirror': Parameter 'granularity' expects a value in range [512B, 64MB] Signed-off-by: Shanzhi Yu s...@redhat.com --- src/qemu/qemu_driver.c | 4 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d1f195c..0eca8ed 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16990,6 +16990,10 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml, virReportError(VIR_ERR_INVALID_ARG, %s, _(granularity must be power of 2)); goto cleanup; +} else if (param-value.ui 65536 || param-value.ui 4096) { +virReportError(VIR_ERR_INVALID_ARG, %s, + _(granularity expects value in range [4096 65536])); +goto cleanup; } granularity = param-value.ui; } else if (STREQ(param-field, VIR_DOMAIN_BLOCK_COPY_BUF_SIZE)) { -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 00/13] Admin API
On Tue, Jun 16, 2015 at 11:58:17AM +0200, Martin Kletzander wrote: This is a real post for an Admin API to get in. Everything discussed in previous posts should be a addressed. I'll start a discussion later on today about the ideas for the APIs to be added and the general near-future desing moves. I'm also keeping the last three example patches in so you can try that it works. Martin Kletzander (13): Move daemon-related parts of virNetServer to virNetDaemon tests: Adapt virnetservertest to daemon refactor Teach gendispatch how to handle admin dispatching files Add admin protocol Build client headers for admin protocol Add admin error domain Add libvirt-admin library Add XML files with admin API specification Add configuration options for permissions on daemon's admin socket Add support for admin API in libvirt daemon ACK to merge of these patches - 1 comment inline rpc: Add virNetServerGetNClients admin: Add virAdmHello function Example virt-admin Regards, 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
[libvirt] [EXAMPLE PATCH 11/13] rpc: Add virNetServerGetNClients
This function accesses the number of connected clients while properly locking the server it returns the data about. Signed-off-by: Martin Kletzander mklet...@redhat.com --- src/libvirt_remote.syms | 1 + src/rpc/virnetserver.c | 10 ++ src/rpc/virnetserver.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index e6ca041ea8e1..8ddb10ed7b31 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -99,6 +99,7 @@ virNetServerAddClient; virNetServerAddProgram; virNetServerAddService; virNetServerClose; +virNetServerGetNClients; virNetServerHasClients; virNetServerKeepAliveRequired; virNetServerNew; diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 60a9714f6096..1f4fbaed3c99 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -884,3 +884,13 @@ virNetServerStart(virNetServerPtr srv) return virNetServerMDNSStart(srv-mdns); } + +size_t +virNetServerGetNClients(virNetServerPtr srv) +{ +size_t ret = 0; +virObjectLock(srv); +ret = srv-nclients; +virObjectUnlock(srv); +return ret; +} diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h index 5c28182ffd15..e0852843f05c 100644 --- a/src/rpc/virnetserver.h +++ b/src/rpc/virnetserver.h @@ -90,4 +90,6 @@ void virNetServerUpdateServices(virNetServerPtr srv, bool enabled); int virNetServerStart(virNetServerPtr srv); +size_t virNetServerGetNClients(virNetServerPtr srv); + #endif /* __VIR_NET_SERVER_H__ */ -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] PING: [PATCH v2 0/2] Allow PCI virtio on ARM virt machine
Hello ? Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -Original Message- From: libvir-list-boun...@redhat.com [mailto:libvir-list-boun...@redhat.com] On Behalf Of Pavel Fedin Sent: Thursday, June 11, 2015 9:41 AM To: libvir-list@redhat.com Cc: Pavel Fedin Subject: [libvirt] [PATCH v2 0/2] Allow PCI virtio on ARM virt machine Virt machine in qemu since v2.3.0 has PCI generic host controller, and can use PCI devices. This provides performance improvement as well as vhost-net with irqfd support for virtio-net. However libvirt still insists on virtio devices attached to virt machine to have MMIO bindings. This patch allows to use both. If the user doesn't specify address type='virtio-mmio', PCI will be used by default. Changes since v1: - Added capability based on qemu version number - Recognize also virt- prefix Pavel Fedin (2): Introduce QEMU_CAPS_ARM_VIRT_PCI Allow PCI virtio on ARM virt machine src/qemu/qemu_capabilities.c | 5 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 15 --- 3 files changed, 18 insertions(+), 3 deletions(-) -- 1.9.5.msysgit.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 2/4] gvir_config_domain_filesys_set_driver_type: replace the driver node
Replace the driver node in case the user calls the function more than one time. --- libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c index 006a407..dc49bcd 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c @@ -125,7 +125,7 @@ void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys GVirConfigObject *node; g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys)); -node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), driver); +node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node)); if (type != GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT) gvir_config_object_set_attribute_with_type( -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [sandbox v2 2/4] Write /dev/vd* instead of vd* in mounts.cfg
Fixes a regression introduced by d74b4350: the init-qemu tool expects /dev/vd* sources to create the block device, while we were just having vd*. Write again /dev/vd* to mounts.cfg. --- libvirt-sandbox/libvirt-sandbox-builder-machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c index 35a5816..c446447 100644 --- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c +++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c @@ -303,7 +303,7 @@ static gboolean gvir_sandbox_builder_machine_write_mount_cfg(GVirSandboxConfig * fstype = 9p; options = g_strdup(trans=virtio,version=9p2000.u); } else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_IMAGE(mconfig)) { -source = g_strdup_printf(vd%c, (char)('a' + nHostImage++)); +source = g_strdup_printf(/dev/vd%c, (char)('a' + nHostImage++)); fstype = ext3; options = g_strdup(); } else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_GUEST_BIND(mconfig)) { -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2] nodeinfo: fix to parse present cpus rather than possible cpus
Currently we are parsing all the possible cpus to get the nodeinfo. This fix will perform a check for present cpus before parsing. Signed-off-by: Kothapally Madhu Pavan k...@linux.vnet.ibm.com --- src/nodeinfo.c | 13 + 1 file changed, 13 insertions(+) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 2fafe2d..0134aba 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -57,6 +57,7 @@ #define VIR_FROM_THIS VIR_FROM_NONE VIR_LOG_INIT(nodeinfo); +virBitmapPtr nodeGetPresentCPUBitmap(void); #if defined(__FreeBSD__) || defined(__APPLE__) static int @@ -418,6 +419,7 @@ virNodeParseNode(const char *node, int processors = 0; DIR *cpudir = NULL; struct dirent *cpudirent = NULL; +virBitmapPtr present_cpumap = NULL; int sock_max = 0; cpu_set_t sock_map; int sock; @@ -438,12 +440,18 @@ virNodeParseNode(const char *node, goto cleanup; } +present_cpumap = nodeGetPresentCPUBitmap(); + /* enumerate sockets in the node */ CPU_ZERO(sock_map); while ((direrr = virDirRead(cpudir, cpudirent, node)) 0) { if (sscanf(cpudirent-d_name, cpu%u, cpu) != 1) continue; +if (present_cpumap) +if (!(virBitmapIsBitSet(present_cpumap, cpu))) +continue; + if ((online = virNodeGetCpuValue(node, cpu, online, 1)) 0) goto cleanup; @@ -477,6 +485,10 @@ virNodeParseNode(const char *node, if (sscanf(cpudirent-d_name, cpu%u, cpu) != 1) continue; +if (present_cpumap) +if (!(virBitmapIsBitSet(present_cpumap, cpu))) +continue; + if ((online = virNodeGetCpuValue(node, cpu, online, 1)) 0) goto cleanup; @@ -537,6 +549,7 @@ virNodeParseNode(const char *node, ret = -1; } VIR_FREE(core_maps); +virBitmapFree(present_cpumap); return ret; } -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list