Re: [libvirt] [glib] Don't overwrite filesystem type when writing format
On Tue, 2015-07-07 at 17:31 +0200, Christophe Fergeau wrote: This is unintuitive, but after looking at the code and a quick test, I think _add_child() will create the node if it does not exist, and return the existing node if it already exists. So I think this could become: +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), driver); Waooh, indeed, not intuitive at all ;) I'll use that one then. -- Cedric -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] qemu: Make virtio-9p-ccw the default for s390-ccw-virtio machines
For s390-ccw-virtio machines the default bus type is set to ccw. Specifing an address element allows to override the default. Signed-off-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com Reviewed-by: Jason J. Herne jjhe...@us.ibm.com Reviewed-by: Stefan Zimmermann s...@linux.vnet.ibm.com --- src/qemu/qemu_command.c | 8 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 58f3d9c..fc2a1bd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1273,6 +1273,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, declare address-less virtio devices to be of address type 'type' disks, networks, consoles, controllers, memballoon and rng in this order + if type is ccw filesystem devices are declared to be of address type ccw */ size_t i; @@ -1309,6 +1310,13 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, def-rngs[i]-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def-rngs[i]-info.type = type; } + +if (type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { +for (i = 0; i def-nfss; i++) { +if (def-fss[i]-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) +def-fss[i]-info.type = type; +} +} } -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/3] qemu: virtio-9p-ccw support
Adding support and a test for virtio-9p-ccw. Changing the default from virtio-9p-pci to virtio-9p-ccw for s390-ccw-virtio machines. Boris Fiuczynski (3): qemu: Support for virtio-9p-ccw qemu: Make virtio-9p-ccw the default for s390-ccw-virtio machines qemu: Test for virtio-9p-ccw support src/qemu/qemu_command.c | 14 - tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args | 16 ++ tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.xml | 36 +++ tests/qemuxml2argvtest.c | 4 +++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.xml -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib PATCHv5 7/7] gobject: Add wrapper for virNetworkGetDHCPLeases
Hi all, Christophe pointed out that this and the previous patch binds API that was added an year ago: commit: 03e0e79e07622496522609741734c2fdcacb5bf2 Author: Nehal J Wani nehaljw.k...@gmail.com Date: Tue Jun 24 02:31:49 2014 +0530 net-dhcp-leases: Implement the public APIs Introduce 3 new APIs, virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC and virNetworkDHCPLeaseFree. --- While I think 1 year old is pretty old enough to justify bumping the dep to that version, Christophe thinks its still too soon. I'd hate to go through the trouble of adding ugly #ifdef around these new API but if others (I guess mainly Dan?) agree with Christophe, I can do that. On Tue, Jul 7, 2015 at 4:26 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: On Tue, Jul 7, 2015 at 3:17 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: --- libvirt-gobject/libvirt-gobject-network.c | 55 +++ libvirt-gobject/libvirt-gobject-network.h | 4 +++ libvirt-gobject/libvirt-gobject.sym | 2 ++ 3 files changed, 61 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c index b1b38a0..2a7bed6 100644 --- a/libvirt-gobject/libvirt-gobject-network.c +++ b/libvirt-gobject/libvirt-gobject-network.c @@ -29,6 +29,7 @@ #include libvirt-glib/libvirt-glib.h #include libvirt-gobject/libvirt-gobject.h #include libvirt-gobject-compat.h +#include libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h #define GVIR_NETWORK_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_NETWORK, GVirNetworkPrivate)) @@ -224,3 +225,57 @@ GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network, free(xml); return conf; } + +/** + * gvir_network_get_dhcp_leases: + * @network: the network + * @mac: (allow-none): The optional ASCII formatted MAC address of an interface + * @flags: placeholder for flags, must be 0 + * + * @err: Place-holder for possible errors + * + * This function fetches leases info of guests in the specified network. If the + * optional parameter @mac is specified, the returned list will contain only + * lease info about a specific guest interface with @mac. There can be multiple + * leases for a single @mac because this API supports DHCPv6 too. + * + * Returns: (element-type LibvirtGObject.NetworkDHCPLease) (transfer full): the + * list of network leases. Each object in the returned list should be unreffed + * with g_object_unref() and the list itself using g_list_free, when no longer + * needed. + */ +GList *gvir_network_get_dhcp_leases(GVirNetwork *network, +const char* mac, +guint flags, +GError **err) +{ +virNetworkDHCPLeasePtr *leases; +GList *ret = NULL; +int num_leases, i; + +g_return_val_if_fail(GVIR_IS_NETWORK(network), NULL); +g_return_val_if_fail(err == NULL || *err == NULL, NULL); +g_return_val_if_fail(flags != 0, NULL); Oh, this should be flags == 0. I'll fix before pushing. -- Regards, Zeeshan Ali (Khattak) Befriend GNOME: http://www.gnome.org/friends/ -- Regards, Zeeshan Ali (Khattak) Befriend GNOME: http://www.gnome.org/friends/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Don't allow duplicated targets regardless of bus
ping^2 Tks, John On 06/18/2015 04:12 PM, John Ferlan wrote: https://bugzilla.redhat.com/show_bug.cgi?id=1142631 Commit id 'e0e290552' added a check to determine if the same bus had the same target value. It seems that's not quite good enough as the check should check the target name value regardless of bus type. Also added a DO_TEST_DIFFERENT to exhibit the issue Signed-off-by: John Ferlan jfer...@redhat.com --- src/conf/domain_conf.c | 3 +- .../qemuxml2argv-disk-same-targets.xml | 35 ++ tests/qemuxml2argvtest.c | 3 ++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b10f6cd..7855bcb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12590,8 +12590,7 @@ virDomainDiskDefDstDuplicates(virDomainDefPtr def) for (i = 1; i def-ndisks; i++) { for (j = 0; j i; j++) { -if (def-disks[i]-bus == def-disks[j]-bus -STREQ(def-disks[i]-dst, def-disks[j]-dst)) { +if (STREQ(def-disks[i]-dst, def-disks[j]-dst)) { virReportError(VIR_ERR_XML_ERROR, _(target '%s' duplicated for disk sources '%s' and '%s'), diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml new file mode 100644 index 000..3276ce5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-same-targets.xml @@ -0,0 +1,35 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory + vcpu placement='static'1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_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'/ +/disk +disk type='file' device='disk' + source file='/tmp/usbdisk.img'/ + target dev='sda' bus='usb'/ +/disk +disk type='file' device='disk' + source file='/tmp/idedisk.img'/ + target dev='sda' bus='ide'/ +/disk +disk type='file' device='disk' + source file='/tmp/scsidisk.img'/ + target dev='sda' bus='scsi'/ +/disk +memballoon model='virtio'/ + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index be82dd2..b066681 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -882,6 +882,9 @@ mymain(void) QEMU_CAPS_DEVICE); DO_TEST(disk-snapshot, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT); +DO_TEST_FAILURE(disk-same-targets, +QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_SCSI_LSI, +QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG); DO_TEST(event_idx, QEMU_CAPS_DRIVE, QEMU_CAPS_VIRTIO_BLK_EVENT_IDX, -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib PATCHv5 7/7] gobject: Add wrapper for virNetworkGetDHCPLeases
On Tue, Jul 7, 2015 at 3:17 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: --- libvirt-gobject/libvirt-gobject-network.c | 55 +++ libvirt-gobject/libvirt-gobject-network.h | 4 +++ libvirt-gobject/libvirt-gobject.sym | 2 ++ 3 files changed, 61 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c index b1b38a0..2a7bed6 100644 --- a/libvirt-gobject/libvirt-gobject-network.c +++ b/libvirt-gobject/libvirt-gobject-network.c @@ -29,6 +29,7 @@ #include libvirt-glib/libvirt-glib.h #include libvirt-gobject/libvirt-gobject.h #include libvirt-gobject-compat.h +#include libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h #define GVIR_NETWORK_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_NETWORK, GVirNetworkPrivate)) @@ -224,3 +225,57 @@ GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network, free(xml); return conf; } + +/** + * gvir_network_get_dhcp_leases: + * @network: the network + * @mac: (allow-none): The optional ASCII formatted MAC address of an interface + * @flags: placeholder for flags, must be 0 + * + * @err: Place-holder for possible errors + * + * This function fetches leases info of guests in the specified network. If the + * optional parameter @mac is specified, the returned list will contain only + * lease info about a specific guest interface with @mac. There can be multiple + * leases for a single @mac because this API supports DHCPv6 too. + * + * Returns: (element-type LibvirtGObject.NetworkDHCPLease) (transfer full): the + * list of network leases. Each object in the returned list should be unreffed + * with g_object_unref() and the list itself using g_list_free, when no longer + * needed. + */ +GList *gvir_network_get_dhcp_leases(GVirNetwork *network, +const char* mac, +guint flags, +GError **err) +{ +virNetworkDHCPLeasePtr *leases; +GList *ret = NULL; +int num_leases, i; + +g_return_val_if_fail(GVIR_IS_NETWORK(network), NULL); +g_return_val_if_fail(err == NULL || *err == NULL, NULL); +g_return_val_if_fail(flags != 0, NULL); Oh, this should be flags == 0. I'll fix before pushing. -- Regards, Zeeshan Ali (Khattak) Befriend GNOME: http://www.gnome.org/friends/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 2/3] Add PCI-Express root to ARM virt machine
Hello! Is there a way where we would make this configurable? Since the virt machine types use the MMIO bus by default we should make the PCI bus configurable since not everybody might want to add it actually. What exactly do you mean? In qemu this is not configurable, it's just there. If you don't want to use it, just don't use it. I see no harm done by adding description of it to domain XML. If you just add a device, and don't specify address type='pci', it will default to address type='virtio-mmio' as before. Nothing will change regarding old behavior and backwards compatibility. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib PATCHv4 1/7] gobject: Simplify gvir_connection_list*() implementations
On Wed, Jul 01, 2015 at 09:40:45PM +0100, Zeeshan Ali (Khattak) wrote: @@ -901,77 +801,31 @@ gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn, if (g_cancellable_set_error_if_cancelled(cancellable, err)) goto cleanup; -active = fetch_list(vconn, -Storage Pools, -virConnectNumOfStoragePools, -virConnectListStoragePools, -cancellable, -nactive, -lerr); -if (lerr) { -g_propagate_error(err, lerr); -lerr = NULL; +npools = virConnectListAllStoragePools(vconn, vpools, 0); +if (npools 0) { +gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + _(Failed to fetch list of pools)); goto cleanup; } if (g_cancellable_set_error_if_cancelled(cancellable, err)) goto cleanup; -inactive = fetch_list(vconn, - Storage Pools, - virConnectNumOfDefinedStoragePools, - virConnectListDefinedStoragePools, - cancellable, - ninactive, - lerr); -if (lerr) { -g_propagate_error(err, lerr); -lerr = NULL; -goto cleanup; -} - pools = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); -for (i = 0 ; i nactive ; i++) { +for (i = 0 ; i npools; i++) { if (g_cancellable_set_error_if_cancelled(cancellable, err)) goto cleanup; -virStoragePoolPtr vpool; GVirStoragePool *pool; While touching this code, you could move 'pool' declaration to the beginning of the 'for' block. Christophe pgpwQe7D6YB9K.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v4 0/2] Fix nodeinfo output on PPC64 KVM hosts
Changes from v3 to v4: * removed a printf() statement; * fixed typo in a commit message. Shivaprasad G Bhat (2): Fix nodeinfo output on PPC64 KVM hosts Add testcase for PPC64 kvm host nodeinfo src/libvirt_private.syms | 1 + src/nodeinfo.c | 138 +++-- src/nodeinfo.h | 1 + tests/Makefile.am | 6 + tests/nodeinfodata/linux-ppc64-subcores.cpuinfo| 59 + tests/nodeinfodata/linux-ppc64-subcores.expected | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu0/online | 1 + .../linux-subcores/cpu/cpu0/physical_id| 1 + .../linux-subcores/cpu/cpu0/topology/core_id | 1 + .../linux-subcores/cpu/cpu0/topology/core_siblings | 1 + .../cpu/cpu0/topology/core_siblings_list | 1 + .../cpu/cpu0/topology/physical_package_id | 1 + .../cpu/cpu0/topology/thread_siblings | 1 + .../cpu/cpu0/topology/thread_siblings_list | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu1/online | 1 + .../linux-subcores/cpu/cpu1/physical_id| 1 + tests/nodeinfodata/linux-subcores/cpu/cpu10/online | 1 + .../linux-subcores/cpu/cpu10/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu11/online | 1 + .../linux-subcores/cpu/cpu11/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu12/online | 1 + .../linux-subcores/cpu/cpu12/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu13/online | 1 + .../linux-subcores/cpu/cpu13/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu14/online | 1 + .../linux-subcores/cpu/cpu14/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu15/online | 1 + .../linux-subcores/cpu/cpu15/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu16/online | 1 + .../linux-subcores/cpu/cpu16/physical_id | 1 + .../linux-subcores/cpu/cpu16/topology/core_id | 1 + .../cpu/cpu16/topology/core_siblings | 1 + .../cpu/cpu16/topology/core_siblings_list | 1 + .../cpu/cpu16/topology/physical_package_id | 1 + .../cpu/cpu16/topology/thread_siblings | 1 + .../cpu/cpu16/topology/thread_siblings_list| 1 + tests/nodeinfodata/linux-subcores/cpu/cpu17/online | 1 + .../linux-subcores/cpu/cpu17/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu18/online | 1 + .../linux-subcores/cpu/cpu18/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu19/online | 1 + .../linux-subcores/cpu/cpu19/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu2/online | 1 + .../linux-subcores/cpu/cpu2/physical_id| 1 + tests/nodeinfodata/linux-subcores/cpu/cpu20/online | 1 + .../linux-subcores/cpu/cpu20/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu21/online | 1 + .../linux-subcores/cpu/cpu21/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu22/online | 1 + .../linux-subcores/cpu/cpu22/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu23/online | 1 + .../linux-subcores/cpu/cpu23/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu24/online | 1 + .../linux-subcores/cpu/cpu24/physical_id | 1 + .../linux-subcores/cpu/cpu24/topology/core_id | 1 + .../cpu/cpu24/topology/core_siblings | 1 + .../cpu/cpu24/topology/core_siblings_list | 1 + .../cpu/cpu24/topology/physical_package_id | 1 + .../cpu/cpu24/topology/thread_siblings | 1 + .../cpu/cpu24/topology/thread_siblings_list| 1 + tests/nodeinfodata/linux-subcores/cpu/cpu25/online | 1 + .../linux-subcores/cpu/cpu25/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu26/online | 1 + .../linux-subcores/cpu/cpu26/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu27/online | 1 + .../linux-subcores/cpu/cpu27/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu28/online | 1 + .../linux-subcores/cpu/cpu28/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu29/online | 1 + .../linux-subcores/cpu/cpu29/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu3/online | 1 + .../linux-subcores/cpu/cpu3/physical_id| 1 + tests/nodeinfodata/linux-subcores/cpu/cpu30/online | 1 + .../linux-subcores/cpu/cpu30/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu31/online | 1 + .../linux-subcores/cpu/cpu31/physical_id | 1 + tests/nodeinfodata/linux-subcores/cpu/cpu32/online | 1 + .../linux-subcores/cpu/cpu32/physical_id | 1 + .../linux-subcores/cpu/cpu32/topology/core_id | 1 +
[libvirt] [PATCH v4 1/2] Fix nodeinfo output on PPC64 KVM hosts
From: Shivaprasad G Bhat sb...@linux.vnet.ibm.com The nodeinfo is reporting incorrect number of cpus and incorrect host topology on PPC64 KVM hosts. The KVM hypervisor on PPC64 needs only the primary thread in a core to be online, and the secondaries offlined. While scheduling a guest in, the kvm scheduler wakes up the secondaries to run in guest context. The host scheduling of the guests happen at the core level(as only primary thread is online). The kvm scheduler exploits as many threads of the core as needed by guest. Further, starting POWER8, the processor allows splitting a physical core into multiple subcores with 2 or 4 threads each. Again, only the primary thread in a subcore is online in the host. The KVM-PPC scheduler allows guests to exploit all the offline threads in the subcore, by bringing them online when needed. (Kernel patches on split-core http://www.spinics.net/lists/kvm-ppc/msg09121.html) Recently with dynamic micro-threading changes in ppc-kvm, makes sure to utilize all the offline cpus across guests, and across guests with different cpu topologies. (https://www.mail-archive.com/kvm@vger.kernel.org/msg115978.html) Since the offline cpus are brought online in the guest context, it is safe to count them as online. Nodeinfo today discounts these offline cpus from cpu count/topology calclulation, and the nodeinfo output is not of any help and the host appears overcommited when it is actually not. The patch carefully counts those offline threads whose primary threads are online. The host topology displayed by the nodeinfo is also fixed when the host is in valid kvm state. Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com Signed-off-by: Andrea Bolognani abolo...@redhat.com --- src/libvirt_private.syms | 1 + src/nodeinfo.c | 138 ++- src/nodeinfo.h | 1 + 3 files changed, 127 insertions(+), 13 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1566d11..64644a2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1008,6 +1008,7 @@ nodeGetInfo; nodeGetMemory; nodeGetMemoryParameters; nodeGetMemoryStats; +nodeGetThreadsPerSubcore; nodeSetMemoryParameters; diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 2fafe2d..0b78d7d 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -32,6 +32,12 @@ #include sys/utsname.h #include sched.h #include conf/domain_conf.h +#include fcntl.h +#include sys/ioctl.h + +#if HAVE_LINUX_KVM_H +# include linux/kvm.h +#endif #if defined(__FreeBSD__) || defined(__APPLE__) # include sys/time.h @@ -428,28 +434,86 @@ virNodeParseNode(const char *node, unsigned int cpu; int online; int direrr; +int lastonline; +virBitmapPtr cpu_map = NULL; +int threads_per_subcore = 0; *threads = 0; *cores = 0; *sockets = 0; +/* PPC-KVM needs the secondary threads of a core to be offline on the + * host. The kvm scheduler brings the secondary threads online in the + * guest context. Moreover, P8 processor has split-core capability + * where, there can be 1,2 or 4 subcores per core. The primaries of the + * subcores alone will be online on the host for a subcore in the + * host. Even though the actual threads per core for P8 processor is 8, + * depending on the subcores_per_core = 1, 2 or 4, the threads per + * subcore will vary accordingly to 8, 4 and 2 repectively. + * So, On host threads_per_core what is arrived at from sysfs in the + * current logic is actually the subcores_per_core. Threads per subcore + * can only be obtained from the kvm device. For example, on P8 wih 1 + * core having 8 threads, sub_cores_percore=4, the threads 0,2,4 6 + * will be online. The sysfs reflects this and in the current logic + * variable 'threads' will be 4 which is nothing but subcores_per_core. + * If the user tampers the cpu online/offline states using chcpu or other + * means, then it is an unsupported configuration for kvm. + * The code below tries to keep in mind + * - when the libvirtd is run inside a KVM guest or Phyp based guest. + * - Or on the kvm host where user manually tampers the cpu states to + *offline/online randomly. + * On hosts other than POWER this will be 0, in which case a simpler + * thread-counting logic will be used */ +if ((threads_per_subcore = nodeGetThreadsPerSubcore(arch)) 0) +goto cleanup; + +/* Keep track of node CPUs in a bitmap so that we can iterate + * through them in guaranteed numeric order, which is required to + * find out whether a thread is primary or secondary */ +if ((cpu_map = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN)) == NULL) +goto cleanup; + if (!(cpudir = opendir(node))) { virReportSystemError(errno, _(cannot opendir %s), node); goto cleanup; } -/* enumerate sockets in the node */ -
Re: [libvirt] [libvirt-glib PATCHv4 5/7] gobject: Add API to query connection networks
On Wed, Jul 01, 2015 at 09:40:49PM +0100, Zeeshan Ali (Khattak) wrote: Add API to query networks from a connection. --- libvirt-gobject/libvirt-gobject-connection.c | 257 +++ libvirt-gobject/libvirt-gobject-connection.h | 13 +- libvirt-gobject/libvirt-gobject.sym | 6 + 3 files changed, 274 insertions(+), 2 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index 47b6861..a055a86 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -45,6 +45,7 @@ struct _GVirConnectionPrivate GHashTable *domains; GHashTable *pools; GHashTable *interfaces; +GHashTable *networks; }; G_DEFINE_TYPE(GVirConnection, gvir_connection, G_TYPE_OBJECT); @@ -257,6 +258,10 @@ static void gvir_connection_init(GVirConnection *conn) g_str_equal, NULL, g_object_unref); +priv-networks = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); } @@ -672,6 +677,11 @@ void gvir_connection_close(GVirConnection *conn) priv-interfaces = NULL; } +if (priv-networks) { +g_hash_table_unref(priv-networks); +priv-networks = NULL; +} + if (priv-conn) { virConnectDomainEventDeregister(priv-conn, domain_event_cb); virConnectClose(priv-conn); @@ -1696,6 +1706,253 @@ GVirInterface *gvir_connection_find_interface_by_mac(GVirConnection *conn, } /** + * gvir_connection_fetch_networks: + * @conn: a #GVirConnection + * @cancellable: (allow-none)(transfer none): cancellation object + */ +gboolean gvir_connection_fetch_networks(GVirConnection *conn, +GCancellable *cancellable, +GError **err) +{ +GVirConnectionPrivate *priv; +GHashTable *networks; +virNetworkPtr *vnetworks = NULL; +gint nnetworks = 0; +gboolean ret = FALSE; +gint i; +virConnectPtr vconn = NULL; + +g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); +g_return_val_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable), + FALSE); +g_return_val_if_fail((err == NULL) || (*err == NULL), FALSE); + +priv = conn-priv; +g_mutex_lock(priv-lock); +if (!priv-conn) { +g_set_error_literal(err, GVIR_CONNECTION_ERROR, +0, +_(Connection is not open)); +g_mutex_unlock(priv-lock); +goto cleanup; +} +vconn = priv-conn; +/* Stop another thread closing the connection just at the minute */ +virConnectRef(vconn); +g_mutex_unlock(priv-lock); + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +nnetworks = virConnectListAllNetworks(vconn, vnetworks, 0); +if (nnetworks 0) { +gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + _(Failed to fetch list of networks)); +goto cleanup; +} + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +networks = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); + +for (i = 0 ; i nnetworks; i++) { +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +GVirNetwork *network; + +network = GVIR_NETWORK(g_object_new(GVIR_TYPE_NETWORK, +handle, vnetworks[i], +NULL)); +g_hash_table_insert(networks, +(gpointer)gvir_network_get_uuid(network), +network); +} + +g_mutex_lock(priv-lock); +if (priv-networks) +g_hash_table_unref(priv-networks); +priv-networks = networks; +g_mutex_unlock(priv-lock); + +ret = TRUE; + +cleanup: +if (nnetworks 0) { +for (i = 0 ; i nnetworks; i++) +virNetworkFree(vnetworks[i]); +free(vnetworks); +} +if (vconn != NULL) +virConnectClose(vconn); +return ret; +} + +static void +gvir_connection_fetch_networks_helper(GTask *res, + gpointer object, + gpointer task_data G_GNUC_UNUSED, + GCancellable *cancellable) +{ +GVirConnection *conn =
Re: [libvirt] [PATCH v3 1/3] Introduce QEMU_CAPS_ARM_VIRT_PCI
On Mon, Jul 06, 2015 at 15:59:25 +0300, Pavel Fedin wrote: This capability specifies that virt machine on ARM has PCI controller. Enabled when qemu version is at least 2.3.0. Signed-off-by: Pavel Fedin p.fe...@samsung.com --- src/qemu/qemu_capabilities.c | 5 + src/qemu/qemu_capabilities.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 27686c3..0dc034f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c ... @@ -3352,6 +3353,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, qemuCaps-version = 2003000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF); +/* 'virt' machine has PCI controller from v2.3.0 onwards */ +if (qemuCaps-version = 2003000) +virQEMUCapsSet(qemuCaps, QEMU_CAPS_ARM_VIRT_PCI); Is there a way how we could detect this according to the actual presence of the PCI bus for the ARM machine? A certain device type that can be queried rather than relying on a version check. (see virQEMUCapsObjectTypes[] and other similar arrays in src/qemu/qemu_caps.c) Generally the approach is to use a specific device check to set capabilities for anything where it's possible since it's robust against backports of given functionality to previous versions. + /* vhost-user supports multi-queue from v2.4.0 onwards, * but there is no way to query for that capability */ if (qemuCaps-version = 2004000) 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 v3 1/2] Fix nodeinfo output on PPC64 KVM hosts
On Mon, 2015-07-06 at 17:34 +0530, Shivaprasad bhat wrote: Thanks a lot Andrea. The cleanups are really nice. I had a chance to test the patch and it seems to work consistently in all sucores_per_core modes. Only two comments written inline . Glad you're happy with the changes! +nodeGetThreadsPerSubcore; The nodeGetThreadsPerSubcore being PPC specific, is it good to have it in nodeinfo.h ? That was the rational on which I had the ioctl wrapper written in virarch.c in v2. Even though it's ppc64 specific, all the logic that uses that function and needs to take the value of threads_per_subcore into account is already part of that file, so I think it makes sense to have it there. The maintainers might disagree, of course :) +if (virBitmapSetBit(cpu_map, cpu) 0) { +printf(virBitmapSetBit(%d)\n, cpu); Using printf here. May be you wanted virReportError(?). I think we can ignore the SetBit return, given this is from directory parsing. That was indeed not supposed to be there, good catch! I've removed it and posted v4 of the series. Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] Qemu: add CMT support
On Jul 6, 2015 14:49, Prerna wrote: On Sun, Jul 5, 2015 at 5:13 PM, Qiaowei Ren qiaowei@intel.com mailto:qiaowei@intel.com wrote: One RFC in https://www.redhat.com/archives/libvir-list/2015-June/msg01509.html CMT (Cache Monitoring Technology) can be used to measure the usage of cache by VM running on the host. This patch will extend the bulk stats API (virDomainListGetStats) to add this field. Applications based on libvirt can use this API to achieve cache usage of VM. Because CMT implementation in Linux kernel is based on perf mechanism, this patch will enable perf event for CMT when VM is created and disable it when VM is destroyed. Hi Ren, One query wrt this implementation. I see you make a perf ioctl to gather CMT stats each time the stats API is invoked. If the CMT stats are exposed by a hardware counter, then this implies logging on a per-cpu (or per-socket ???) basis. This also implies that the value read will vary as the CPU (or socket) on which it is being called changes. Now, with this background, if we need real-world stats on a VM, we need this perf ioctl executed on all CPUs/ sockets on which the VM ran. Also, once done, we will need to aggregate results from each of these sources. In this implementation, I am missing this -- there seems no control over which physical CPU the libvirt worker thread will run and collect the perf data from. Data collected from this implementation might not accurately model the system state. I _think_ libvirt currently has no way of directing a worker thread to collect stats from a given CPU -- if we do, I would be happy to learn about it :) Prerna, thanks for your reply. I checked the CMT implementation in kernel, and noticed that the series implement new -count() of pmu driver which can aggregate the results from each cpu if perf type is PERF_TYPE_INTEL_CQM . The following is the link for the patch: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=bfe1fcd2688f557a6b6a88f59ea7619228728bd7 So I guess that this patch just need to set right perf type and cpu=-1. Do you think this is ok? Thanks, Qiaowei -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib PATCHv4 3/7] gobject: Port GVirConnection to GTask
On Wed, Jul 01, 2015 at 09:40:47PM +0100, Zeeshan Ali (Khattak) wrote: GSimpleAsyncResult has been deprecated in favour of GTask and with latest glib headers, we get tons of warnings about use of deprecated API. This patch ports the GVirConnection class to GTask. --- libvirt-gobject/libvirt-gobject-connection.c | 246 --- 1 file changed, 110 insertions(+), 136 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index dddbd3a..f7a6066 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -497,17 +497,18 @@ gboolean gvir_connection_open_read_only(GVirConnection *conn, } static void -gvir_connection_open_helper(GSimpleAsyncResult *res, -GObject *object, +gvir_connection_open_helper(GTask *res, I'd have a strong preference for GTask *task throughout the patch rather than GTask *res +gpointer object, +gpointer task_data G_GNUC_UNUSED, GCancellable *cancellable) { GVirConnection *conn = GVIR_CONNECTION(object); GError *err = NULL; -if (!gvir_connection_open(conn, cancellable, err)) { -g_simple_async_result_set_from_error(res, err); -g_error_free(err); -} +if (!gvir_connection_open(conn, cancellable, err)) +g_task_return_error(res, err); +else +g_task_return_boolean(res, TRUE); } @@ -523,19 +524,19 @@ void gvir_connection_open_async(GVirConnection *conn, GAsyncReadyCallback callback, gpointer user_data) { -GSimpleAsyncResult *res; +GTask *res; g_return_if_fail(GVIR_IS_CONNECTION(conn)); g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable)); -res = g_simple_async_result_new(G_OBJECT(conn), -callback, -user_data, -gvir_connection_open_async); -g_simple_async_result_run_in_thread(res, -gvir_connection_open_helper, -G_PRIORITY_DEFAULT, -cancellable); +res = g_task_new(G_OBJECT(conn), + cancellable, + callback, + user_data); +g_task_set_source_tag(res, + gvir_connection_open_async); You set the source tag, but never use it, you're missing a g_task_get_source_tag() check if the async complete callback. [snip] @@ -1760,21 +1744,18 @@ gvir_connection_restore_domain_from_file_async(GVirConnection *conn, data-custom_conf = g_object_ref(custom_conf); data-flags = flags; -res = g_simple_async_result_new - (G_OBJECT(conn), - callback, - user_data, +res = g_task_new (G_OBJECT(conn), Nit: Extra space before opening parens Christophe pgpFs5H_1l7ub.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 2/3] Add PCI-Express root to ARM virt machine
On Mon, Jul 06, 2015 at 15:59:26 +0300, Pavel Fedin wrote: Add PCI Express root complex if the corresponding capability is present Signed-off-by: Pavel Fedin p.fe...@samsung.com --- src/qemu/qemu_domain.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f9bf32c..36f411d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c ... @@ -1030,12 +1030,16 @@ qemuDomainDefPostParse(virDomainDefPtr def, break; case VIR_ARCH_ARMV7L: - addDefaultUSB = false; - addDefaultMemballoon = false; - break; case VIR_ARCH_AARCH64: addDefaultUSB = false; addDefaultMemballoon = false; + if (STREQ(def-os.machine, virt) || + STRPREFIX(def-os.machine, virt-)) { + virQEMUDriverPtr driver = opaque; + virQEMUCapsPtr qemuCaps = + virQEMUCapsCacheLookup(driver-qemuCapsCache, def-emulator); + addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_ARM_VIRT_PCI); Is there a way where we would make this configurable? Since the virt machine types use the MMIO bus by default we should make the PCI bus configurable since not everybody might want to add it actually. + } break; case VIR_ARCH_PPC64: -- 1.9.5.msysgit.0 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] vz: use PRL_USE_VNET_NAME_FOR_BRIDGE_NAME
On 07/07/2015 04:49 AM, Maxim Nestratov wrote: It is better not to assume that newly created network should be connected to a bridge with same name, but specify it explicitly by PRL_USE_VNET_NAME_FOR_BRIDGE_NAME flag. Signed-off-by: Maxim Nestratov mnestra...@virtuozzo.com There is a typo in libvirt list name, but as I remember, there was an alias. Did it get there? --- src/vz/vz_sdk.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 1b66958..1c56655 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -2834,7 +2834,9 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, pret = PrlVirtNet_SetNetworkType(vnet, PVN_BRIDGED_ETHERNET); prlsdkCheckRetGoto(pret, cleanup); -job = PrlSrv_AddVirtualNetwork(privconn-server, vnet, 0); +job = PrlSrv_AddVirtualNetwork(privconn-server, + vnet, + PRL_USE_VNET_NAME_FOR_BRIDGE_NAME); if (PRL_FAILED(pret = waitJob(job))) goto cleanup; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] qemu: Test for virtio-9p-ccw support
This patch adds a test for the qemu command line generation. Signed-off-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com Reviewed-by: Jason J. Herne jjhe...@us.ibm.com Reviewed-by: Stefan Zimmermann s...@linux.vnet.ibm.com --- tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args | 16 ++ tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.xml | 36 +++ tests/qemuxml2argvtest.c | 4 +++ 3 files changed, 56 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args new file mode 100644 index 000..8d2f21a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.args @@ -0,0 +1,16 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M s390-ccw-virtio -m 214 -smp 1 \ +-nographic -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 -device \ +virtio-blk-ccw,devno=fe.0.,drive=drive-virtio-disk0,id=virtio-disk0 \ +-fsdev local,security_model=passthrough,id=fsdev-fs0,\ +path=/export/to/guest -device virtio-9p-ccw,id=fs0,fsdev=fsdev-fs0,\ +mount_tag=/import/from/host,devno=fe.0.0001 \ +-fsdev local,security_model=mapped,writeout=immediate,id=fsdev-fs1,\ +path=/export/to/guest2 -device virtio-9p-ccw,id=fs1,fsdev=fsdev-fs1,\ +mount_tag=/import/from/host2,devno=fe.0.0002 \ +-fsdev handle,writeout=immediate,id=fsdev-fs2,\ +path=/export/to/guest3 -device virtio-9p-ccw,id=fs2,fsdev=fsdev-fs2,\ +mount_tag=/import/from/host3,devno=fe.0.0003 \ +-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0004 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.xml b/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.xml new file mode 100644 index 000..860e34b --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-fs9p-ccw.xml @@ -0,0 +1,36 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory + vcpu placement='static'1/vcpu + os +type arch='s390x' machine='s390-ccw-virtio'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='virtio'/ +/disk +filesystem type='mount' + source dir='/export/to/guest'/ + target dir='/import/from/host'/ +/filesystem +filesystem accessmode='mapped' + driver type='path' wrpolicy='immediate'/ + source dir='/export/to/guest2'/ + target dir='/import/from/host2'/ +/filesystem +filesystem + driver type='handle' wrpolicy='immediate'/ + source dir='/export/to/guest3'/ + target dir='/import/from/host3'/ +/filesystem + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 574777b..d3f09b1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1219,6 +1219,10 @@ mymain(void) DO_TEST(fs9p, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV, QEMU_CAPS_FSDEV_WRITEOUT); +DO_TEST(fs9p-ccw, +QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV, +QEMU_CAPS_FSDEV_WRITEOUT, QEMU_CAPS_DRIVE, +QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); DO_TEST(hostdev-usb-address, NONE); DO_TEST(hostdev-usb-address-device, -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [glib] Don't overwrite filesystem type when writing format
On Tue, Jul 07, 2015 at 06:24:38PM +0200, Cedric Bosdonnat wrote: On Tue, 2015-07-07 at 17:31 +0200, Christophe Fergeau wrote: This is unintuitive, but after looking at the code and a quick test, I think _add_child() will create the node if it does not exist, and return the existing node if it already exists. So I think this could become: +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), driver); Waooh, indeed, not intuitive at all ;) I'll use that one then. We could try to change the name to something better, but I can't really think of a good name :( Christophe pgpfRsduCwFHx.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/1] vz: assign static IPs and default gateways for network adapter
On 07/07/2015 04:38 PM, Mikhail Feoktistov wrote: We support only one IPv4 and one IPv6 default gateway. If static IPs are not present in instance config, then we switch on DHCP for this adapter. PrlVmDevNet_SetAutoApply to makes necessary settings within guest OS In linux case it creates network startup scripts /etc/sysconfig/network-scripts/ifcfg-ethN and fills it with necessary parameters. Thanks, Acked and pushed. --- src/vz/vz_sdk.c | 126 +++ 1 files changed, 126 insertions(+), 0 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 1b66958..1b8298c 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -2762,8 +2762,13 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, PRL_HANDLE sdknet = PRL_INVALID_HANDLE; PRL_HANDLE vnet = PRL_INVALID_HANDLE; PRL_HANDLE job = PRL_INVALID_HANDLE; +PRL_HANDLE addrlist = PRL_INVALID_HANDLE; +size_t i; int ret = -1; char macstr[PRL_MAC_STRING_BUFNAME]; +char *addrstr = NULL; +bool ipv6present = false; +bool ipv4present = false; if (prlsdkCheckNetUnsupportedParams(net) 0) return -1; @@ -2788,6 +2793,125 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, pret = PrlVmDevNet_SetMacAddress(sdknet, macstr); prlsdkCheckRetGoto(pret, cleanup); +pret = PrlApi_CreateStringsList(addrlist); +prlsdkCheckRetGoto(pret, cleanup); + +for (i = 0; i net-nips; i++) { +char *tmpstr; + +if (AF_INET == VIR_SOCKET_ADDR_FAMILY(net-ips[i]-address)) +ipv4present = true; +else if (AF_INET6 == VIR_SOCKET_ADDR_FAMILY(net-ips[i]-address)) +ipv6present = true; +else +continue; + +if (!(tmpstr = virSocketAddrFormat(net-ips[i]-address))) +goto cleanup; + +if (virAsprintf(addrstr, %s/%d, tmpstr, net-ips[i]-prefix) 0) { +VIR_FREE(tmpstr); +goto cleanup; +} + +VIR_FREE(tmpstr); +pret = PrlStrList_AddItem(addrlist, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +VIR_FREE(addrstr); +} + +if (ipv4present || ipv6present) { +pret = PrlVmDevNet_SetNetAddresses(sdknet, addrlist); +prlsdkCheckRetGoto(pret, cleanup); +} + +pret = PrlVmDevNet_SetConfigureWithDhcp(sdknet, !ipv4present); +prlsdkCheckRetGoto(pret, cleanup); + +pret = PrlVmDevNet_SetConfigureWithDhcpIPv6(sdknet, !ipv6present); +prlsdkCheckRetGoto(pret, cleanup); + +pret = PrlVmDevNet_SetAutoApply(sdknet, true); +prlsdkCheckRetGoto(pret, cleanup); + +if (net-nroutes) { +bool alreadySetIPv4Gateway = false; +bool alreadySetIPv6Gateway = false; + +for (i = 0; i net-nroutes; i++) { +virSocketAddrPtr addrdst, gateway; +virSocketAddr zero; + +addrdst = virNetworkRouteDefGetAddress(net-routes[i]); +gateway = virNetworkRouteDefGetGateway(net-routes[i]); + +ignore_value(virSocketAddrParse(zero, +(VIR_SOCKET_ADDR_IS_FAMILY(addrdst, AF_INET) + ? VIR_SOCKET_ADDR_IPV4_ALL + : VIR_SOCKET_ADDR_IPV6_ALL), +VIR_SOCKET_ADDR_FAMILY(addrdst))); + +if (!virSocketAddrEqual(addrdst, zero)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Support only default gateway)); +goto cleanup; +} + +switch (VIR_SOCKET_ADDR_FAMILY(gateway)) { +case AF_INET: + +if (!ipv4present) +continue; + +if (alreadySetIPv4Gateway) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Support only one IPv4 default gateway)); +goto cleanup; +} + +if (!(addrstr = virSocketAddrFormat(gateway))) +goto cleanup; + +pret = PrlVmDevNet_SetDefaultGateway(sdknet, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +alreadySetIPv4Gateway = true; +break; + +case AF_INET6: + +if (!ipv6present) +continue; + +if (alreadySetIPv6Gateway) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Support only one IPv6 default gateway)); +goto cleanup; +} + +if (!(addrstr = virSocketAddrFormat(gateway))) +goto cleanup; + +pret = PrlVmDevNet_SetDefaultGatewayIPv6(sdknet, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +alreadySetIPv6Gateway = true; +break; + +default: +
[libvirt] [libvirt-glib PATCHv5 7/7] gobject: Add wrapper for virNetworkGetDHCPLeases
--- libvirt-gobject/libvirt-gobject-network.c | 55 +++ libvirt-gobject/libvirt-gobject-network.h | 4 +++ libvirt-gobject/libvirt-gobject.sym | 2 ++ 3 files changed, 61 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c index b1b38a0..2a7bed6 100644 --- a/libvirt-gobject/libvirt-gobject-network.c +++ b/libvirt-gobject/libvirt-gobject-network.c @@ -29,6 +29,7 @@ #include libvirt-glib/libvirt-glib.h #include libvirt-gobject/libvirt-gobject.h #include libvirt-gobject-compat.h +#include libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h #define GVIR_NETWORK_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_NETWORK, GVirNetworkPrivate)) @@ -224,3 +225,57 @@ GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network, free(xml); return conf; } + +/** + * gvir_network_get_dhcp_leases: + * @network: the network + * @mac: (allow-none): The optional ASCII formatted MAC address of an interface + * @flags: placeholder for flags, must be 0 + * + * @err: Place-holder for possible errors + * + * This function fetches leases info of guests in the specified network. If the + * optional parameter @mac is specified, the returned list will contain only + * lease info about a specific guest interface with @mac. There can be multiple + * leases for a single @mac because this API supports DHCPv6 too. + * + * Returns: (element-type LibvirtGObject.NetworkDHCPLease) (transfer full): the + * list of network leases. Each object in the returned list should be unreffed + * with g_object_unref() and the list itself using g_list_free, when no longer + * needed. + */ +GList *gvir_network_get_dhcp_leases(GVirNetwork *network, +const char* mac, +guint flags, +GError **err) +{ +virNetworkDHCPLeasePtr *leases; +GList *ret = NULL; +int num_leases, i; + +g_return_val_if_fail(GVIR_IS_NETWORK(network), NULL); +g_return_val_if_fail(err == NULL || *err == NULL, NULL); +g_return_val_if_fail(flags != 0, NULL); + +num_leases = virNetworkGetDHCPLeases(network-priv-handle, mac, leases, flags); +if (num_leases 0) { +gvir_set_error_literal(err, GVIR_NETWORK_ERROR, + 0, + Unable to get network DHCP leases); +return NULL; +} + +if (num_leases == 0) +return NULL; + +for (i = 0; i num_leases; i++) { +GVirNetworkDHCPLease *lease; + +lease = gvir_network_dhcp_lease_new(leases[i]); +ret = g_list_prepend(ret, lease); +} +ret = g_list_reverse(ret); +free(leases); + +return ret; +} diff --git a/libvirt-gobject/libvirt-gobject-network.h b/libvirt-gobject/libvirt-gobject-network.h index 9f746c0..5617ed6 100644 --- a/libvirt-gobject/libvirt-gobject-network.h +++ b/libvirt-gobject/libvirt-gobject-network.h @@ -71,6 +71,10 @@ const gchar *gvir_network_get_uuid(GVirNetwork *network); GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network, guint flags, GError **err); +GList *gvir_network_get_dhcp_leases(GVirNetwork *network, +const char* mac, +guint flags, +GError **err); G_END_DECLS diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index dfd858a..ca89a45 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -300,6 +300,8 @@ LIBVIRT_GOBJECT_0.2.2 { gvir_network_dhcp_lease_get_mac; gvir_network_dhcp_lease_get_prefix; gvir_network_dhcp_lease_get_type; + + gvir_network_get_dhcp_leases; } LIBVIRT_GOBJECT_0.2.1; # define new API here using predicted next version number -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 00/10] Restore code to allow unpriv_sgio for hostdev SCSI generic
On 07/07/2015 08:19 AM, Peter Krempa wrote: On Mon, Jul 06, 2015 at 13:08:28 -0400, John Ferlan wrote: v1 here: http://www.redhat.com/archives/libvir-list/2015-June/msg00814.html Changes since v1: - Add doc patch 1 to indicate that this feature may only be supported by certain kernels - Adjust former patch 1 to add call to qemuIsSharedHostdev from qemuSetUnprivSGIO - Insert patches 7 8 which essentially refactor qemuSetUnprivSGIO a bit. There should be no functional difference - Patch 9 is now a much slimmer former patch 6 The end result is that 'generically speaking' if any kernel supports setting the unprivileged SGIO feature, then these patches provide the capability to do so. Although as pointed out in the review of v1 only one specific downstream kernel supports the feature, that doesn't mean other distros couldn't add support in the same manner. So rather than just remove all traces from libvirt completely, it seems it would be reasonable to keep the checks in place and if a kernel then decides to add support this code exists to assist. Well, I'm not going to insist that we revert the existing code since it's possible that the feature might actually make it into the upstream linux kernel eventually. Until it's upstream I don't think though we should add support (even if we document that it will not work) for stuff that is not upstream since the design of the upstream interface might then differ, which will make us carry two implementations. This series merely addresses adding back the hostdev changes using the same processing as disk except for where the sgio bit is stored and handled for hostdev. The unpriv_sgio for disk is already in libvirt as of 1.0.2 and if I read between the lines correctly, that's not in the upstream kernel either, but I cannot state that for sure. If unpriv_sgio doesn't exist upstream for disk and could cause us to carry two implementations if done differently, then I don't see how having hostdev have the same implementation as disk is problematic. Or am I misreading what you wrote? My assumption being that whatever is done upstream would use the same mechanism for disk and hostdev as it does now for the downstream implementation. Since there's already existing code that touches the kernel interface for unpriv_sgio, actually exposing the support will then require us to carry that part instead of changing it to the actual upstream impl. If a hypothetical downstream distro would add kernel patches to add the feature, they might as well as carry the downstream libvirt patches too. NACK series until upstream kernel support is present. (Some of the cleanup patches may be worth taking until the kernel issue gets settled though.) Right w/r/t taking some of these patches... This is something I pointed out in the original series, but since this is a new series here's my thoughts... Patch 1 changes to entirely remove the text about sgio in hostdev. Patch 2 seems OK with a slight text adjustment on the commit message Patches 3-8 adjust the shared hostdev logic regardless of unpriv sgio Patches 9 10 could then become downstream only, at least for now. Much smaller subset of changes than the original add/revert (and there's I think 2 less bugs from what was there, plus the extra one you found in patch 7 that would have been cleaned up by patch 9 - although I'll contend that's an ordering thing - I did 9 first and then thought that 7 8 would things more logical). Since there are ACK's for 2 and 8, I can assume to a degree you agree with my thoughts through patch 8. There's no explicit ACK's on other patches, although there is an explicit NACK to the whole series, so I'll wait before doing anything with this to see your and others thoughts regarding what is or should be applicable. I've already adjusted in my local branch patch 2, 7, 8. Tks - John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [glib] Don't overwrite filesystem type when writing format
Hey, On Tue, Jul 07, 2015 at 04:26:02PM +0200, Cédric Bosdonnat wrote: When setting filesystem driver format first and type, only the type remained and vice-versa. --- libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 8 ++-- tests/test-gconfig.c | 2 +- tests/xml/gconfig-domain-device-filesys.xml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c index 9b73af5..4e33d5f 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c @@ -125,7 +125,9 @@ 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_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); +node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), driver); +if (!node) +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), driver); This is unintuitive, but after looking at the code and a quick test, I think _add_child() will create the node if it does not exist, and return the existing node if it already exists. So I think this could become: +node = gvir_config_object_add_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( @@ -143,7 +145,9 @@ void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *files GVirConfigObject *node; g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys)); -node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); +node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), driver); +if (!node) +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), driver); and same here. Christophe pgp9xvoJ5zSRh.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/3] qemu: Support for virtio-9p-ccw
Adding the recently in qemu added 9pfs support for virtio-ccw. Signed-off-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com Reviewed-by: Jason J. Herne jjhe...@us.ibm.com Reviewed-by: Stefan Zimmermann s...@linux.vnet.ibm.com --- src/qemu/qemu_command.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 25a7bc6..58f3d9c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4386,7 +4386,11 @@ qemuBuildFSDevStr(virDomainDefPtr def, goto error; } -virBufferAddLit(opt, virtio-9p-pci); +if (fs-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) +virBufferAddLit(opt, virtio-9p-ccw); +else +virBufferAddLit(opt, virtio-9p-pci); + virBufferAsprintf(opt, ,id=%s, fs-info.alias); virBufferAsprintf(opt, ,fsdev=%s%s, QEMU_FSDEV_HOST_PREFIX, fs-info.alias); virBufferAsprintf(opt, ,mount_tag=%s, fs-dst); -- 1.8.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [glib] Add filesys xml file to distribution
On Tue, Jul 07, 2015 at 04:49:16PM +0200, Cédric Bosdonnat wrote: Tests can't succeed from the distribution tarball: the new gconfig-domain-device-filesys.xml file wasn't included. --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 63865e8..c8bb4c7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,6 +23,7 @@ EXTRA_DIST += \ xml/gconfig-domain-device-channel.xml \ xml/gconfig-domain-device-console.xml \ xml/gconfig-domain-device-disk.xml \ + xml/gconfig-domain-device-filesys.xml \ xml/gconfig-domain-device-graphics.xml \ xml/gconfig-domain-device-input.xml \ xml/gconfig-domain-device-network.xml \ This could be EXTRA_DIST = xml I think, this way we won't forget next time we add a file there! Christophe pgpftd29GVA0S.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] libxl: rework setting the state of virDomainObj
Set the state of virDomainObj in the functions that actually change the domain state, instead of the generic libxlDomainCleanup function. This approach gives functions calling libxlDomainCleanup more flexibility wrt when and how they change virDomainObj state via virDomainObjSetState. The prior approach of calling virDomainObjSetState in libxlDomainCleanup resulted in the following incorrect coding pattern in the various functions that change domain state libxlDomainDoStateTransition call libxl function to do state transition emit lifecycle event libxlDomainCleanup virDomainObjSetState Once simple manifestation of this bug is seeing a domain running in virt-manager after selecting the shutdown button, even after the domain has long shutdown. Signed-off-by: Jim Fehlig jfeh...@suse.com --- I considered emitting the lifecycle event in libxlDomainCleanup, but IMO it is best to change the state and emit the event where where the state change actually occurs. src/libxl/libxl_domain.c| 23 --- src/libxl/libxl_domain.h| 3 +-- src/libxl/libxl_driver.c| 28 ++-- src/libxl/libxl_migration.c | 8 ++-- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 8e8a292..224ff77 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -397,7 +397,6 @@ libxlDomainShutdownThread(void *opaque) libxlDriverPrivatePtr driver = shutdown_info-driver; virObjectEventPtr dom_event = NULL; libxl_shutdown_reason xl_reason = ev-u.domain_shutdown.shutdown_reason; -virDomainShutoffReason reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN; libxlDriverConfigPtr cfg; cfg = libxlDriverConfigGet(driver); @@ -406,12 +405,14 @@ libxlDomainShutdownThread(void *opaque) goto cleanup; if (xl_reason == LIBXL_SHUTDOWN_REASON_POWEROFF) { +virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, + VIR_DOMAIN_SHUTOFF_SHUTDOWN); + dom_event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); switch ((virDomainLifecycleAction) vm-def-onPoweroff) { case VIR_DOMAIN_LIFECYCLE_DESTROY: -reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN; goto destroy; case VIR_DOMAIN_LIFECYCLE_RESTART: case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME: @@ -421,12 +422,14 @@ libxlDomainShutdownThread(void *opaque) goto endjob; } } else if (xl_reason == LIBXL_SHUTDOWN_REASON_CRASH) { +virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, + VIR_DOMAIN_SHUTOFF_CRASHED); + dom_event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_CRASHED); switch ((virDomainLifecycleCrashAction) vm-def-onCrash) { case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY: -reason = VIR_DOMAIN_SHUTOFF_CRASHED; goto destroy; case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART: case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME: @@ -442,12 +445,14 @@ libxlDomainShutdownThread(void *opaque) goto restart; } } else if (xl_reason == LIBXL_SHUTDOWN_REASON_REBOOT) { +virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, + VIR_DOMAIN_SHUTOFF_SHUTDOWN); + dom_event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); switch ((virDomainLifecycleAction) vm-def-onReboot) { case VIR_DOMAIN_LIFECYCLE_DESTROY: -reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN; goto destroy; case VIR_DOMAIN_LIFECYCLE_RESTART: case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME: @@ -467,7 +472,7 @@ libxlDomainShutdownThread(void *opaque) dom_event = NULL; } libxlDomainDestroyInternal(driver, vm); -libxlDomainCleanup(driver, vm, reason); +libxlDomainCleanup(driver, vm); if (!vm-persistent) virDomainObjListRemove(driver-domains, vm); @@ -479,7 +484,7 @@ libxlDomainShutdownThread(void *opaque) dom_event = NULL; } libxlDomainDestroyInternal(driver, vm); -libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN); +libxlDomainCleanup(driver, vm); if (libxlDomainStart(driver, vm, false, -1) 0) { virErrorPtr err = virGetLastError(); VIR_ERROR(_(Failed to restart VM '%s': %s), @@ -685,8 +690,7 @@ libxlDomainDestroyInternal(libxlDriverPrivatePtr driver, */ void libxlDomainCleanup(libxlDriverPrivatePtr driver, - virDomainObjPtr vm, - virDomainShutoffReason
[libvirt] [PATCH 6/9] nodeinfo: Add sysfs_prefix to nodeGetInfo
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_SYSTEM_PATH. Signed-off-by: John Ferlan jfer...@redhat.com --- src/bhyve/bhyve_capabilities.c | 2 +- src/bhyve/bhyve_driver.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/nodeinfo.c | 9 ++--- src/nodeinfo.h | 2 +- src/openvz/openvz_conf.c | 2 +- src/openvz/openvz_driver.c | 2 +- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/uml/uml_driver.c | 2 +- src/vbox/vbox_common.c | 2 +- src/vz/vz_driver.c | 4 ++-- 12 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index e6d5518..3a55879 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -51,7 +51,7 @@ virBhyveCapsInitCPU(virCapsPtr caps, cpu-arch = arch; -if (nodeGetInfo(nodeinfo)) +if (nodeGetInfo(NULL, nodeinfo)) goto error; cpu-type = VIR_CPU_TYPE_HOST; diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 68dff6c..ba411a0 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1131,7 +1131,7 @@ bhyveNodeGetInfo(virConnectPtr conn, if (virNodeGetInfoEnsureACL(conn) 0) return -1; -return nodeGetInfo(nodeinfo); +return nodeGetInfo(NULL, nodeinfo); } static int diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 31201a0..e0e72ea 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5400,7 +5400,7 @@ lxcNodeGetInfo(virConnectPtr conn, if (virNodeGetInfoEnsureACL(conn) 0) return -1; -return nodeGetInfo(nodeinfo); +return nodeGetInfo(NULL, nodeinfo); } diff --git a/src/nodeinfo.c b/src/nodeinfo.c index bf4f751..2d715fd 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -1034,7 +1034,8 @@ virNodeGetSiblingsList(const char *dir, int cpu_id) } #endif -int nodeGetInfo(virNodeInfoPtr nodeinfo) +int nodeGetInfo(const char *sysfs_prefix ATTRIBUTE_UNUSED, +virNodeInfoPtr nodeinfo) { virArch hostarch = virArchFromHost(); @@ -1046,14 +1047,16 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo) #ifdef __linux__ { int ret = -1; +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; FILE *cpuinfo = fopen(CPUINFO_PATH, r); + if (!cpuinfo) { virReportSystemError(errno, _(cannot open %s), CPUINFO_PATH); return -1; } -ret = linuxNodeInfoCPUPopulate(cpuinfo, SYSFS_SYSTEM_PATH, +ret = linuxNodeInfoCPUPopulate(cpuinfo, prefix, hostarch, nodeinfo); if (ret 0) goto cleanup; @@ -1666,7 +1669,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED) int id, cid; int onlinecpus ATTRIBUTE_UNUSED; -if (nodeGetInfo(nodeinfo) 0) +if (nodeGetInfo(NULL, nodeinfo) 0) return -1; ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo); diff --git a/src/nodeinfo.h b/src/nodeinfo.h index 9e6904f..ec53769 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -26,7 +26,7 @@ # include capabilities.h -int nodeGetInfo(virNodeInfoPtr nodeinfo); +int nodeGetInfo(const char *sysfs_prefix, virNodeInfoPtr nodeinfo); int nodeCapsInitNUMA(virCapsPtr caps); int nodeGetCPUStats(int cpuNum, diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 49d78c6..a4c5c31 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -637,7 +637,7 @@ openvzGetNodeCPUs(void) { virNodeInfo nodeinfo; -if (nodeGetInfo(nodeinfo) 0) +if (nodeGetInfo(NULL, nodeinfo) 0) return 0; return nodeinfo.cpus; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index fc6f101..280b998 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -2155,7 +2155,7 @@ static int openvzNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) { -return nodeGetInfo(nodeinfo); +return nodeGetInfo(NULL, nodeinfo); } diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 27686c3..6532011 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -960,7 +960,7 @@ virQEMUCapsInitCPU(virCapsPtr caps, cpu-arch = arch; -if (nodeGetInfo(nodeinfo)) +if (nodeGetInfo(NULL, nodeinfo)) goto error; cpu-type = VIR_CPU_TYPE_HOST; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3382b9a..b26b1a8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18377,7 +18377,7 @@ qemuNodeGetInfo(virConnectPtr conn, if (virNodeGetInfoEnsureACL(conn) 0) return -1; -return nodeGetInfo(nodeinfo); +return nodeGetInfo(NULL, nodeinfo); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index
[libvirt] [PATCH 5/9] nodeinfo: Add sysfs_prefix to nodeGetCPUMap
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_SYSTEM_PATH. Signed-off-by: John Ferlan jfer...@redhat.com --- src/bhyve/bhyve_driver.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/nodeinfo.c | 8 +--- src/nodeinfo.h | 3 ++- src/openvz/openvz_driver.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/uml/uml_driver.c | 2 +- src/vz/vz_driver.c | 2 +- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index dc76cf7..68dff6c 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1299,7 +1299,7 @@ bhyveNodeGetCPUMap(virConnectPtr conn, if (virNodeGetCPUMapEnsureACL(conn) 0) return -1; -return nodeGetCPUMap(cpumap, online, flags); +return nodeGetCPUMap(NULL, cpumap, online, flags); } static int diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index cc1277b..31201a0 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5553,7 +5553,7 @@ lxcNodeGetCPUMap(virConnectPtr conn, if (virNodeGetCPUMapEnsureACL(conn) 0) return -1; -return nodeGetCPUMap(cpumap, online, flags); +return nodeGetCPUMap(NULL, cpumap, online, flags); } diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 75e0a02..bf4f751 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -1624,10 +1624,12 @@ nodeGetMemoryParameters(virTypedParameterPtr params ATTRIBUTE_UNUSED, } int -nodeGetCPUMap(unsigned char **cpumap, +nodeGetCPUMap(const char *sysfs_prefix, + unsigned char **cpumap, unsigned int *online, unsigned int flags) { +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; virBitmapPtr cpus = NULL; int maxpresent; int ret = -1; @@ -1636,9 +1638,9 @@ nodeGetCPUMap(unsigned char **cpumap, virCheckFlags(0, -1); if (!cpumap !online) -return nodeGetCPUCount(NULL); +return nodeGetCPUCount(prefix); -if (!(cpus = nodeGetCPUBitmap(NULL, maxpresent))) +if (!(cpus = nodeGetCPUBitmap(prefix, maxpresent))) goto cleanup; if (cpumap virBitmapToData(cpus, cpumap, dummy) 0) diff --git a/src/nodeinfo.h b/src/nodeinfo.h index 439ef35..9e6904f 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -55,7 +55,8 @@ int nodeSetMemoryParameters(virTypedParameterPtr params, int nparams, unsigned int flags); -int nodeGetCPUMap(unsigned char **cpumap, +int nodeGetCPUMap(const char *sysfs_prefix, + unsigned char **cpumap, unsigned int *online, unsigned int flags); diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index d1a327c..fc6f101 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -2207,7 +2207,7 @@ openvzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned int *online, unsigned int flags) { -return nodeGetCPUMap(cpumap, online, flags); +return nodeGetCPUMap(NULL, cpumap, online, flags); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6fbe68a..3382b9a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18472,7 +18472,7 @@ qemuNodeGetCPUMap(virConnectPtr conn, if (virNodeGetCPUMapEnsureACL(conn) 0) return -1; -return nodeGetCPUMap(cpumap, online, flags); +return nodeGetCPUMap(NULL, cpumap, online, flags); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 7a95458..99162f7 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2877,7 +2877,7 @@ umlNodeGetCPUMap(virConnectPtr conn, if (virNodeGetCPUMapEnsureACL(conn) 0) return -1; -return nodeGetCPUMap(cpumap, online, flags); +return nodeGetCPUMap(NULL, cpumap, online, flags); } diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 06fb579..bc82444 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -868,7 +868,7 @@ vzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned int *online, unsigned int flags) { -return nodeGetCPUMap(cpumap, online, flags); +return nodeGetCPUMap(NULL, cpumap, online, flags); } static int -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/9] nodeinfo: Add sysfs_prefix to nodeGetCPUBitmap
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_SYSTEM_PATH. Signed-off-by: John Ferlan jfer...@redhat.com --- src/nodeinfo.c | 24 src/nodeinfo.h | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 34de720..75e0a02 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -1275,29 +1275,35 @@ nodeGetPresentCPUBitmap(const char *sysfs_prefix) } virBitmapPtr -nodeGetCPUBitmap(int *max_id ATTRIBUTE_UNUSED) +nodeGetCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED, + int *max_id ATTRIBUTE_UNUSED) { #ifdef __linux__ +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; +char *online_path = NULL; virBitmapPtr cpumap; int present; -present = nodeGetCPUCount(NULL); +present = nodeGetCPUCount(prefix); if (present 0) return NULL; -if (virFileExists(SYSFS_SYSTEM_PATH /cpu/online)) { -cpumap = linuxParseCPUmap(present, SYSFS_SYSTEM_PATH /cpu/online); +if (virAsprintf(online_path, %s/cpu/online, prefix) 0) +return NULL; +if (virFileExists(online_path)) { +cpumap = linuxParseCPUmap(present, online_path); } else { size_t i; cpumap = virBitmapNew(present); if (!cpumap) -return NULL; +goto cleanup; for (i = 0; i present; i++) { -int online = virNodeGetCpuValue(SYSFS_SYSTEM_PATH, i, online, 1); +int online = virNodeGetCpuValue(prefix, i, online, 1); if (online 0) { virBitmapFree(cpumap); -return NULL; +cpumap = NULL; +goto cleanup; } if (online) ignore_value(virBitmapSetBit(cpumap, i)); @@ -1305,6 +1311,8 @@ nodeGetCPUBitmap(int *max_id ATTRIBUTE_UNUSED) } if (max_id cpumap) *max_id = present; + cleanup: +VIR_FREE(online_path); return cpumap; #else virReportError(VIR_ERR_NO_SUPPORT, %s, @@ -1630,7 +1638,7 @@ nodeGetCPUMap(unsigned char **cpumap, if (!cpumap !online) return nodeGetCPUCount(NULL); -if (!(cpus = nodeGetCPUBitmap(maxpresent))) +if (!(cpus = nodeGetCPUBitmap(NULL, maxpresent))) goto cleanup; if (cpumap virBitmapToData(cpus, cpumap, dummy) 0) diff --git a/src/nodeinfo.h b/src/nodeinfo.h index 3ef206b..439ef35 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -44,7 +44,7 @@ int nodeGetMemory(unsigned long long *mem, unsigned long long *freeMem); virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix); -virBitmapPtr nodeGetCPUBitmap(int *max_id); +virBitmapPtr nodeGetCPUBitmap(const char *sysfs_prefix, int *max_id); int nodeGetCPUCount(const char *sysfs_prefix); int nodeGetMemoryParameters(virTypedParameterPtr params, -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 8/9] nodeinfo: Add sysfs_prefix to nodeGetMemoryStats
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_SYSTEM_PATH. Signed-off-by: John Ferlan jfer...@redhat.com --- src/bhyve/bhyve_driver.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/nodeinfo.c | 6 -- src/nodeinfo.h | 3 ++- src/openvz/openvz_driver.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/uml/uml_driver.c | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index ba411a0..85b7c8f 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1121,7 +1121,7 @@ bhyveNodeGetMemoryStats(virConnectPtr conn, if (virNodeGetMemoryStatsEnsureACL(conn) 0) return -1; -return nodeGetMemoryStats(cellNum, params, nparams, flags); +return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags); } static int diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index e0e72ea..81bb711 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5486,7 +5486,7 @@ lxcNodeGetMemoryStats(virConnectPtr conn, if (virNodeGetMemoryStatsEnsureACL(conn) 0) return -1; -return nodeGetMemoryStats(cellNum, params, nparams, flags); +return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags); } diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 5ff5ce8..3c7e417 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -1141,7 +1141,8 @@ int nodeGetCPUStats(int cpuNum ATTRIBUTE_UNUSED, #endif } -int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED, +int nodeGetMemoryStats(const char *sysfs_prefix ATTRIBUTE_UNUSED, + int cellNum ATTRIBUTE_UNUSED, virNodeMemoryStatsPtr params ATTRIBUTE_UNUSED, int *nparams ATTRIBUTE_UNUSED, unsigned int flags) @@ -1151,6 +1152,7 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED, #ifdef __linux__ { int ret; +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; char *meminfo_path = NULL; FILE *meminfo; int max_node; @@ -1170,7 +1172,7 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED, } if (virAsprintf(meminfo_path, %s/node/node%d/meminfo, -SYSFS_SYSTEM_PATH, cellNum) 0) +prefix, cellNum) 0) return -1; } meminfo = fopen(meminfo_path, r); diff --git a/src/nodeinfo.h b/src/nodeinfo.h index b28aaab..4f983c2 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -33,7 +33,8 @@ int nodeGetCPUStats(int cpuNum, virNodeCPUStatsPtr params, int *nparams, unsigned int flags); -int nodeGetMemoryStats(int cellNum, +int nodeGetMemoryStats(const char *sysfs_prefix, + int cellNum, virNodeMemoryStatsPtr params, int *nparams, unsigned int flags); diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 280b998..fc8db7e 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -2177,7 +2177,7 @@ openvzNodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED, int *nparams, unsigned int flags) { -return nodeGetMemoryStats(cellNum, params, nparams, flags); +return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b26b1a8..8c475ef 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18405,7 +18405,7 @@ qemuNodeGetMemoryStats(virConnectPtr conn, if (virNodeGetMemoryStatsEnsureACL(conn) 0) return -1; -return nodeGetMemoryStats(cellNum, params, nparams, flags); +return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 8606616..c3c5fa7 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2810,7 +2810,7 @@ umlNodeGetMemoryStats(virConnectPtr conn, if (virNodeGetMemoryStatsEnsureACL(conn) 0) return -1; -return nodeGetMemoryStats(cellNum, params, nparams, flags); +return nodeGetMemoryStats(NULL, cellNum, params, nparams, flags); } -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/9] nodeinfo: Add sysfs_prefix to nodeGetPresentCPUBitmap
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_SYSTEM_PATH. Signed-off-by: John Ferlan jfer...@redhat.com --- src/nodeinfo.c | 7 --- src/nodeinfo.h | 2 +- src/util/vircgroup.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 409f922..34de720 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -1249,19 +1249,20 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED) } virBitmapPtr -nodeGetPresentCPUBitmap(void) +nodeGetPresentCPUBitmap(const char *sysfs_prefix) { int max_present; #ifdef __linux__ char *present_path = NULL; virBitmapPtr bitmap = NULL; #endif +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; -if ((max_present = nodeGetCPUCount(NULL)) 0) +if ((max_present = nodeGetCPUCount(prefix)) 0) return NULL; #ifdef __linux__ -if (!(present_path = linuxGetCPUPresentPath(NULL))) +if (!(present_path = linuxGetCPUPresentPath(prefix))) return NULL; if (virFileExists(present_path)) bitmap = linuxParseCPUmap(max_present, present_path); diff --git a/src/nodeinfo.h b/src/nodeinfo.h index 4f9699e..3ef206b 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -43,7 +43,7 @@ int nodeGetCellsFreeMemory(unsigned long long *freeMems, int nodeGetMemory(unsigned long long *mem, unsigned long long *freeMem); -virBitmapPtr nodeGetPresentCPUBitmap(void); +virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix); virBitmapPtr nodeGetCPUBitmap(int *max_id); int nodeGetCPUCount(const char *sysfs_prefix); diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index cbe0234..0ef2d29 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3043,7 +3043,7 @@ virCgroupGetPercpuStats(virCgroupPtr group, } /* To parse account file, we need to know how many cpus are present. */ -if (!(cpumap = nodeGetPresentCPUBitmap())) +if (!(cpumap = nodeGetPresentCPUBitmap(NULL))) return rv; total_cpus = virBitmapSize(cpumap); -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 7/9] nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_CPU_PATH which is a derivative of SYSFS_SYSTEM_PATH Use cpupath for nodeCapsInitNUMAFake and remove SYSFS_CPU_PATH Signed-off-by: John Ferlan jfer...@redhat.com --- src/lxc/lxc_conf.c | 2 +- src/nodeinfo.c | 35 +++ src/nodeinfo.h | 2 +- src/openvz/openvz_conf.c | 2 +- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_capabilities.c | 2 +- src/uml/uml_conf.c | 2 +- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_conf.c | 2 +- src/vz/vz_driver.c | 2 +- 10 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index c393cb5..b689b92 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -77,7 +77,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) * unexpected failures. We don't want to break the lxc * driver in this scenario, so log errors carry on */ -if (nodeCapsInitNUMA(caps) 0) { +if (nodeCapsInitNUMA(NULL, caps) 0) { virCapabilitiesFreeNUMAInfo(caps); VIR_WARN(Failed to query host NUMA topology, disabling NUMA capabilities); } diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 2d715fd..5ff5ce8 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -283,7 +283,6 @@ freebsdNodeGetMemoryStats(virNodeMemoryStatsPtr params, #ifdef __linux__ # define CPUINFO_PATH /proc/cpuinfo # define SYSFS_SYSTEM_PATH /sys/devices/system -# define SYSFS_CPU_PATH SYSFS_SYSTEM_PATH/cpu # define PROCSTAT_PATH /proc/stat # define MEMINFO_PATH /proc/meminfo # define SYSFS_MEMORY_SHARED_PATH /sys/kernel/mm/ksm @@ -1660,7 +1659,9 @@ nodeGetCPUMap(const char *sysfs_prefix, } static int -nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED) +nodeCapsInitNUMAFake(const char *prefix, + const char *cpupath ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED) { virNodeInfo nodeinfo; virCapsHostNUMACellCPUPtr cpus; @@ -1669,7 +1670,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED) int id, cid; int onlinecpus ATTRIBUTE_UNUSED; -if (nodeGetInfo(NULL, nodeinfo) 0) +if (nodeGetInfo(prefix, nodeinfo) 0) return -1; ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo); @@ -1683,7 +1684,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED) for (c = 0; c nodeinfo.cores; c++) { for (t = 0; t nodeinfo.threads; t++) { #ifdef __linux__ -if (virNodeGetCpuValue(SYSFS_CPU_PATH, id, online, 1)) { +if (virNodeGetCpuValue(cpupath, id, online, 1)) { #endif cpus[cid].id = id; cpus[cid].socket_id = s; @@ -1810,26 +1811,27 @@ nodeGetMemoryFake(unsigned long long *mem, /* returns 1 on success, 0 if the detection failed and -1 on hard error */ static int -virNodeCapsFillCPUInfo(int cpu_id ATTRIBUTE_UNUSED, +virNodeCapsFillCPUInfo(const char *cpupath, + int cpu_id ATTRIBUTE_UNUSED, virCapsHostNUMACellCPUPtr cpu ATTRIBUTE_UNUSED) { #ifdef __linux__ int tmp; cpu-id = cpu_id; -if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id, +if ((tmp = virNodeGetCpuValue(cpupath, cpu_id, topology/physical_package_id, -1)) 0) return 0; cpu-socket_id = tmp; -if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id, +if ((tmp = virNodeGetCpuValue(cpupath, cpu_id, topology/core_id, -1)) 0) return 0; cpu-core_id = tmp; -if (!(cpu-siblings = virNodeGetSiblingsList(SYSFS_CPU_PATH, cpu_id))) +if (!(cpu-siblings = virNodeGetSiblingsList(cpupath, cpu_id))) return -1; return 0; @@ -1917,8 +1919,11 @@ virNodeCapsGetPagesInfo(int node, } int -nodeCapsInitNUMA(virCapsPtr caps) +nodeCapsInitNUMA(const char *sysfs_prefix, + virCapsPtr caps) { +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; +char *cpupath; int n; unsigned long long memory; virCapsHostNUMACellCPUPtr cpus = NULL; @@ -1933,8 +1938,13 @@ nodeCapsInitNUMA(virCapsPtr caps) bool topology_failed = false; int max_node; -if (!virNumaIsAvailable()) -return nodeCapsInitNUMAFake(caps); +if (virAsprintf(cpupath, %s/cpu, prefix) 0) +return -1; + +if (!virNumaIsAvailable()) { +ret = nodeCapsInitNUMAFake(prefix, cpupath, caps); +goto cleanup; +} if ((max_node = virNumaGetMaxNode()) 0) goto cleanup; @@ -1955,7 +1965,7 @@ nodeCapsInitNUMA(virCapsPtr caps) for (i = 0; i virBitmapSize(cpumap); i++) { if (virBitmapIsBitSet(cpumap, i)) { -if (virNodeCapsFillCPUInfo(i, cpus + cpu++) 0) { +if
[libvirt] [PATCH 0/9] Add sysfs_prefix to nodeinfo.c API's
This series adds/processes a sysfs_prefix for the nodeinfo.c API's. Although the nodeinfotest.c passes a local test directory path, it was never used. This was all brought to light by patch 9 in this series which is essentially Kothapally Madhu Pavan's v3 patch: http://www.redhat.com/archives/libvir-list/2015-June/msg00395.html With the adjustment to call nodeGetPresentCPUBitmap and virNodeParseNode with the sysfs prefix. Without the first 5 patches, the patch as posted caused nodeinfotest failure in my test environment which doesn't have the larger environments that the test tried to set up because the test environment used my present mask file. John Ferlan (8): nodeinfo: Introduce local linuxGetCPUPresentPath nodeinfo: Add sysfs_prefix to nodeGetCPUCount nodeinfo: Add sysfs_prefix to nodeGetPresentCPUBitmap nodeinfo: Add sysfs_prefix to nodeGetCPUBitmap nodeinfo: Add sysfs_prefix to nodeGetCPUMap nodeinfo: Add sysfs_prefix to nodeGetInfo nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA nodeinfo: Add sysfs_prefix to nodeGetMemoryStats Kothapally Madhu Pavan (1): nodeinfo: fix to parse present cpus rather than possible cpus src/bhyve/bhyve_capabilities.c | 2 +- src/bhyve/bhyve_driver.c | 6 +- src/lxc/lxc_conf.c | 2 +- src/lxc/lxc_controller.c | 2 +- src/lxc/lxc_driver.c | 6 +- src/nodeinfo.c | 159 + src/nodeinfo.h | 16 +++-- src/openvz/openvz_conf.c | 4 +- src/openvz/openvz_driver.c | 6 +- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_capabilities.c | 4 +- src/qemu/qemu_driver.c | 16 ++--- src/qemu/qemu_process.c| 2 +- src/uml/uml_conf.c | 2 +- src/uml/uml_driver.c | 6 +- src/util/vircgroup.c | 2 +- src/vbox/vbox_common.c | 4 +- src/vmware/vmware_conf.c | 2 +- src/vz/vz_driver.c | 10 +-- src/vz/vz_sdk.c| 2 +- tests/vircgrouptest.c | 4 +- 21 files changed, 166 insertions(+), 93 deletions(-) -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 9/9] nodeinfo: fix to parse present cpus rather than possible cpus
From: Kothapally Madhu Pavan k...@linux.vnet.ibm.com This patch resolves a situation where a core is defective and is not in the present mask during boot. Optionally a host can have empty sockets could be brought online if the socket is added. In this case the present mask contains the cpu's that are actually there in the sockets even though they might be offline for some reason. This patch excludes the cpu's that are offline because the socket is defective/empty by checking the present mask before reading the cpu directory. Otherwise, the nodeinfo on such hosts always displays wrong output which includes the defective/empty sockets as set of offline cpu's. Signed-off-by: Kothapally Madhu Pavan k...@linux.vnet.ibm.com Signed-off-by: John Ferlan jfer...@redhat.com --- src/nodeinfo.c | 23 ++- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 3c7e417..1d8a339 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -43,6 +43,7 @@ #include c-ctype.h #include viralloc.h #include nodeinfopriv.h +#include nodeinfo.h #include physmem.h #include virerror.h #include count-one-bits.h @@ -403,20 +404,23 @@ CPU_COUNT(cpu_set_t *set) /* parses a node entry, returning number of processors in the node and * filling arguments */ static int -ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) -ATTRIBUTE_NONNULL(6) -virNodeParseNode(const char *node, +ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(7) +virNodeParseNode(const char *sysfs_prefix, + const char *node, virArch arch, int *sockets, int *cores, int *threads, int *offline) { +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; int ret = -1; 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; @@ -437,12 +441,17 @@ virNodeParseNode(const char *node, goto cleanup; } +present_cpumap = nodeGetPresentCPUBitmap(prefix); + /* 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 !(virBitmapIsBitSet(present_cpumap, cpu))) +continue; + if ((online = virNodeGetCpuValue(node, cpu, online, 1)) 0) goto cleanup; @@ -476,6 +485,9 @@ virNodeParseNode(const char *node, if (sscanf(cpudirent-d_name, cpu%u, cpu) != 1) continue; +if (present_cpumap !(virBitmapIsBitSet(present_cpumap, cpu))) +continue; + if ((online = virNodeGetCpuValue(node, cpu, online, 1)) 0) goto cleanup; @@ -536,6 +548,7 @@ virNodeParseNode(const char *node, ret = -1; } VIR_FREE(core_maps); +virBitmapFree(present_cpumap); return ret; } @@ -657,7 +670,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, sysfs_dir, nodedirent-d_name) 0) goto cleanup; -if ((cpus = virNodeParseNode(sysfs_cpudir, arch, +if ((cpus = virNodeParseNode(sysfs_dir, sysfs_cpudir, arch, socks, cores, threads, offline)) 0) goto cleanup; @@ -688,7 +701,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, if (virAsprintf(sysfs_cpudir, %s/cpu, sysfs_dir) 0) goto cleanup; -if ((cpus = virNodeParseNode(sysfs_cpudir, arch, +if ((cpus = virNodeParseNode(sysfs_dir, sysfs_cpudir, arch, socks, cores, threads, offline)) 0) goto cleanup; -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/9] nodeinfo: Introduce local linuxGetCPUPresentPath
The API will print the path to the /cpu/present file using the sysfs_prefix. NB: This is setup for future patches which will allow local/test sysfs paths. Signed-off-by: John Ferlan jfer...@redhat.com --- src/nodeinfo.c | 43 ++- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 2fafe2d..f3e3108 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -1,7 +1,7 @@ /* * nodeinfo.c: Helper routines for OS specific node information * - * Copyright (C) 2006-2008, 2010-2014 Red Hat, Inc. + * Copyright (C) 2006-2008, 2010-2015 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -944,6 +944,16 @@ linuxNodeGetMemoryStats(FILE *meminfo, return ret; } +static char * +linuxGetCPUPresentPath(const char *sysfs_prefix) +{ +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; +char *path = NULL; + +if (virAsprintf(path, %s/cpu/present, prefix) 0) +return NULL; +return path; +} /* Determine the maximum cpu id from a Linux sysfs cpu/present file. */ static int @@ -1193,27 +1203,34 @@ nodeGetCPUCount(void) * that such kernels also lack hotplug, and therefore cpu/cpuNN * will be consecutive. */ +char *present_path = NULL; char *cpupath = NULL; -int ncpu; +int ncpu = -1; + +if (!(present_path = linuxGetCPUPresentPath(NULL))) +return -1; -if (virFileExists(SYSFS_SYSTEM_PATH /cpu/present)) { -ncpu = linuxParseCPUmax(SYSFS_SYSTEM_PATH /cpu/present); +if (virFileExists(present_path)) { +ncpu = linuxParseCPUmax(present_path); } else if (virFileExists(SYSFS_SYSTEM_PATH /cpu/cpu0)) { ncpu = 0; do { ncpu++; VIR_FREE(cpupath); if (virAsprintf(cpupath, %s/cpu/cpu%d, -SYSFS_SYSTEM_PATH, ncpu) 0) -return -1; +SYSFS_SYSTEM_PATH, ncpu) 0) { +ncpu = -1; +goto cleanup; +} } while (virFileExists(cpupath)); } else { /* no cpu/cpu0: we give up */ virReportError(VIR_ERR_NO_SUPPORT, %s, _(host cpu counting not supported on this node)); -return -1; } + cleanup: +VIR_FREE(present_path); VIR_FREE(cpupath); return ncpu; #elif defined(__FreeBSD__) || defined(__APPLE__) @@ -1229,13 +1246,21 @@ virBitmapPtr nodeGetPresentCPUBitmap(void) { int max_present; +#ifdef __linux__ +char *present_path = NULL; +virBitmapPtr bitmap = NULL; +#endif if ((max_present = nodeGetCPUCount()) 0) return NULL; #ifdef __linux__ -if (virFileExists(SYSFS_SYSTEM_PATH /cpu/present)) -return linuxParseCPUmap(max_present, SYSFS_SYSTEM_PATH /cpu/present); +if (!(present_path = linuxGetCPUPresentPath(NULL))) +return NULL; +if (virFileExists(present_path)) +bitmap = linuxParseCPUmap(max_present, present_path); +VIR_FREE(present_path); +return bitmap; #endif virReportError(VIR_ERR_NO_SUPPORT, %s, _(non-continuous host cpu numbers not implemented on this platform)); -- 2.1.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/9] nodeinfo: Add sysfs_prefix to nodeGetCPUCount
Add the sysfs_prefix argument to the call to allow for setting the path for tests to something other than SYSFS_SYSTEM_PATH. Signed-off-by: John Ferlan jfer...@redhat.com --- src/lxc/lxc_controller.c | 2 +- src/nodeinfo.c | 20 +--- src/nodeinfo.h | 2 +- src/qemu/qemu_driver.c | 10 +- src/qemu/qemu_process.c | 2 +- src/vz/vz_driver.c | 2 +- src/vz/vz_sdk.c | 2 +- tests/vircgrouptest.c| 4 ++-- 8 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 828b8a8..27e2e3a 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -705,7 +705,7 @@ static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl) /* setaffinity fails if you set bits for CPUs which * aren't present, so we have to limit ourselves */ -if ((hostcpus = nodeGetCPUCount()) 0) +if ((hostcpus = nodeGetCPUCount(NULL)) 0) return -1; if (maxcpu hostcpus) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index f3e3108..409f922 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -1195,7 +1195,7 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED, } int -nodeGetCPUCount(void) +nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED) { #if defined(__linux__) /* To support older kernels that lack cpu/present, such as 2.6.18 @@ -1204,21 +1204,27 @@ nodeGetCPUCount(void) * will be consecutive. */ char *present_path = NULL; +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH; char *cpupath = NULL; int ncpu = -1; -if (!(present_path = linuxGetCPUPresentPath(NULL))) +if (!(present_path = linuxGetCPUPresentPath(prefix))) return -1; if (virFileExists(present_path)) { ncpu = linuxParseCPUmax(present_path); -} else if (virFileExists(SYSFS_SYSTEM_PATH /cpu/cpu0)) { +goto cleanup; +} + +if (virAsprintf(cpupath, %s/cpu/cpu0, prefix) 0) +goto cleanup; +if (virFileExists(cpupath)) { ncpu = 0; do { ncpu++; VIR_FREE(cpupath); if (virAsprintf(cpupath, %s/cpu/cpu%d, -SYSFS_SYSTEM_PATH, ncpu) 0) { +prefix, ncpu) 0) { ncpu = -1; goto cleanup; } @@ -1251,7 +1257,7 @@ nodeGetPresentCPUBitmap(void) virBitmapPtr bitmap = NULL; #endif -if ((max_present = nodeGetCPUCount()) 0) +if ((max_present = nodeGetCPUCount(NULL)) 0) return NULL; #ifdef __linux__ @@ -1274,7 +1280,7 @@ nodeGetCPUBitmap(int *max_id ATTRIBUTE_UNUSED) virBitmapPtr cpumap; int present; -present = nodeGetCPUCount(); +present = nodeGetCPUCount(NULL); if (present 0) return NULL; @@ -1621,7 +1627,7 @@ nodeGetCPUMap(unsigned char **cpumap, virCheckFlags(0, -1); if (!cpumap !online) -return nodeGetCPUCount(); +return nodeGetCPUCount(NULL); if (!(cpus = nodeGetCPUBitmap(maxpresent))) goto cleanup; diff --git a/src/nodeinfo.h b/src/nodeinfo.h index 047bd5c..4f9699e 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -45,7 +45,7 @@ int nodeGetMemory(unsigned long long *mem, virBitmapPtr nodeGetPresentCPUBitmap(void); virBitmapPtr nodeGetCPUBitmap(int *max_id); -int nodeGetCPUCount(void); +int nodeGetCPUCount(const char *sysfs_prefix); int nodeGetMemoryParameters(virTypedParameterPtr params, int *nparams, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4cfae03..6fbe68a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1422,7 +1422,7 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm, virVcpuInfoPtr info, int maxinfo, size_t i, v; qemuDomainObjPrivatePtr priv = vm-privateData; -if ((hostcpus = nodeGetCPUCount()) 0) +if ((hostcpus = nodeGetCPUCount(NULL)) 0) return -1; if (priv-vcpupids == NULL) { @@ -5237,7 +5237,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom, if (!(def = virDomainObjGetOneDef(vm, flags))) goto cleanup; -if ((hostcpus = nodeGetCPUCount()) 0) +if ((hostcpus = nodeGetCPUCount(NULL)) 0) goto cleanup; if (!(allcpumap = virBitmapNew(hostcpus))) @@ -5425,7 +5425,7 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, if (!(def = virDomainObjGetOneDef(vm, flags))) goto cleanup; -if ((hostcpus = nodeGetCPUCount()) 0) +if ((hostcpus = nodeGetCPUCount(NULL)) 0) goto cleanup; if (def-cputune.emulatorpin) { @@ -5612,7 +5612,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, goto endjob; } -if ((hostcpus = nodeGetCPUCount()) 0) +if ((hostcpus = nodeGetCPUCount(NULL)) 0) goto endjob; if (VIR_ALLOC_N(info_ret, niothreads) 0) @@ -5672,7 +5672,7 @@
Re: [libvirt] [PATCH v2 02/10] qemu: Introduce qemuIsSharedHostdev
On Mon, Jul 06, 2015 at 13:08:30 -0400, John Ferlan wrote: Add a single boolean function to handle whether the hostdev is shared or not. Use the new function for the qemu{Add|Remove}SharedHostdev calls as well as qemuSetUnprivSGIO. NB: This second usage fixes a possible bug where s/second/third/ if this feature is enabled at some time in the future and the shareable flag wasn't set, the sgio would have been erroneously set. Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index d521886..48fb74a 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1201,6 +1201,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; Since the above condition is: if (condition) return true; else return false; You might as well as return the result of the boolean expression directly since it's equivalent. +} + + static char * qemuGetSharedHostdevKey(virDomainHostdevDefPtr hostdev) { @@ -1238,10 +1251,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))) @@ -1342,10 +1352,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))) @@ -1407,11 +1414,10 @@ 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) { +if (hostdev-source.subsys.u.scsi.sgio) { virReportError(VIR_ERR_INTERNAL_ERROR, %s, _('sgio' is not supported for SCSI generic device yet )); 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 RESEND] Added support for portable-rpcgen from portablexdr library
Hello! I don't think we should use enums at all in the protocol specification. It should be unsigned int and the change should be made separately. Is this hunk here because portable-rpcgen has problems with enum being declared there? Yes, its parser fails. I have checked throughout the code, there are some other enums in .x files too, but when they are put in structs, they are specified without 'enum' keyword and everything is fine. For example, virnetprotocol.x: --- cut --- struct virNetMessageHeader { unsigned prog; /* Unique ID for the program */ unsigned vers; /* Program version number */ int proc; /* Unique ID for the procedure within the program */ virNetMessageType type; /* Type of message */ unsigned serial;/* Serial number of message. */ virNetMessageStatus status; }; --- cut --- Here virNetMessageType and virNetMessageStatus are enums. Actually i borrowed fix method from here. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 1/2] Fix nodeinfo output on PPC64 KVM hosts
On Tue, Jul 07, 2015 at 09:25:59AM +0200, Andrea Bolognani wrote: From: Shivaprasad G Bhat sb...@linux.vnet.ibm.com The nodeinfo is reporting incorrect number of cpus and incorrect host topology on PPC64 KVM hosts. The KVM hypervisor on PPC64 needs only the primary thread in a core to be online, and the secondaries offlined. While scheduling a guest in, the kvm scheduler wakes up the secondaries to run in guest context. The host scheduling of the guests happen at the core level(as only primary thread is online). The kvm scheduler exploits as many threads of the core as needed by guest. Further, starting POWER8, the processor allows splitting a physical core into multiple subcores with 2 or 4 threads each. Again, only the primary thread in a subcore is online in the host. The KVM-PPC scheduler allows guests to exploit all the offline threads in the subcore, by bringing them online when needed. (Kernel patches on split-core http://www.spinics.net/lists/kvm-ppc/msg09121.html) Recently with dynamic micro-threading changes in ppc-kvm, makes sure to utilize all the offline cpus across guests, and across guests with different cpu topologies. (https://www.mail-archive.com/kvm@vger.kernel.org/msg115978.html) Since the offline cpus are brought online in the guest context, it is safe to count them as online. Nodeinfo today discounts these offline cpus from cpu count/topology calclulation, and the nodeinfo output is not of any help and the host appears overcommited when it is actually not. The patch carefully counts those offline threads whose primary threads are online. The host topology displayed by the nodeinfo is also fixed when the host is in valid kvm state. Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com Signed-off-by: Andrea Bolognani abolo...@redhat.com --- src/libvirt_private.syms | 1 + src/nodeinfo.c | 138 ++- src/nodeinfo.h | 1 + 3 files changed, 127 insertions(+), 13 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1566d11..64644a2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1008,6 +1008,7 @@ nodeGetInfo; nodeGetMemory; nodeGetMemoryParameters; nodeGetMemoryStats; +nodeGetThreadsPerSubcore; nodeSetMemoryParameters; diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 2fafe2d..0b78d7d 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -32,6 +32,12 @@ #include sys/utsname.h #include sched.h #include conf/domain_conf.h +#include fcntl.h +#include sys/ioctl.h + +#if HAVE_LINUX_KVM_H +# include linux/kvm.h +#endif #if defined(__FreeBSD__) || defined(__APPLE__) # include sys/time.h @@ -428,28 +434,86 @@ virNodeParseNode(const char *node, unsigned int cpu; int online; int direrr; +int lastonline; +virBitmapPtr cpu_map = NULL; +int threads_per_subcore = 0; *threads = 0; *cores = 0; *sockets = 0; +/* PPC-KVM needs the secondary threads of a core to be offline on the + * host. The kvm scheduler brings the secondary threads online in the + * guest context. Moreover, P8 processor has split-core capability + * where, there can be 1,2 or 4 subcores per core. The primaries of the + * subcores alone will be online on the host for a subcore in the + * host. Even though the actual threads per core for P8 processor is 8, + * depending on the subcores_per_core = 1, 2 or 4, the threads per + * subcore will vary accordingly to 8, 4 and 2 repectively. + * So, On host threads_per_core what is arrived at from sysfs in the + * current logic is actually the subcores_per_core. Threads per subcore + * can only be obtained from the kvm device. For example, on P8 wih 1 + * core having 8 threads, sub_cores_percore=4, the threads 0,2,4 6 + * will be online. The sysfs reflects this and in the current logic + * variable 'threads' will be 4 which is nothing but subcores_per_core. + * If the user tampers the cpu online/offline states using chcpu or other + * means, then it is an unsupported configuration for kvm. + * The code below tries to keep in mind + * - when the libvirtd is run inside a KVM guest or Phyp based guest. + * - Or on the kvm host where user manually tampers the cpu states to + *offline/online randomly. + * On hosts other than POWER this will be 0, in which case a simpler + * thread-counting logic will be used */ +if ((threads_per_subcore = nodeGetThreadsPerSubcore(arch)) 0) +goto cleanup; + +/* Keep track of node CPUs in a bitmap so that we can iterate + * through them in guaranteed numeric order, which is required to + * find out whether a thread is primary or secondary */ +if ((cpu_map = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN)) == NULL) +goto cleanup; + if (!(cpudir = opendir(node))) { virReportSystemError(errno, _(cannot opendir %s), node); goto cleanup; } -/* enumerate
Re: [libvirt] [PATCH v3] qemu: Use heads parameter for QXL driver
On Mon, Jul 06, 2015 at 09:18:59AM +0100, Frediano Ziglio wrote: Allows to specify maximum number of head to QXL driver. The patch to support the max_outputs in Qemu is still not merged but I got agreement on the name of the argument. This shouldn't be part of the commit message, we can't push this in until the code is in qemu anyways, so I'll remove it. Actually can be a compatiblity problem as heads in the XML configuration was set by default to '1'. Signed-off-by: Frediano Ziglio fzig...@redhat.com --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 5 + 3 files changed, 8 insertions(+) Changes from v2: - removed capability tests (Martin Kletzander) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 27686c3..68060cd 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -287,6 +287,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, aarch64-off, vhost-user-multiqueue, /* 190 */ + qxl-vga.max_outputs, ); @@ -1649,6 +1650,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxl[] = { static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxlVga[] = { { vgamem_mb, QEMU_CAPS_QXL_VGA_VGAMEM }, +{ max_outputs, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS }, }; struct virQEMUCapsObjectTypeProps { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 30aa504..02f9e81 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -230,6 +230,7 @@ typedef enum { QEMU_CAPS_DEVICE_PCI_SERIAL = 188, /* -device pci-serial */ QEMU_CAPS_CPU_AARCH64_OFF= 189, /* -cpu ...,aarch64=off */ QEMU_CAPS_VHOSTUSER_MULTIQUEUE = 190, /* vhost-user with -netdev queues= */ +QEMU_CAPS_QXL_VGA_MAX_OUTPUTS = 191, /* qxl-vga.max_outputs */ QEMU_CAPS_LAST, /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 25a7bc6..59666e7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5661,6 +5661,11 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def, /* QEMU accepts mebibytes for vgamem_mb. */ virBufferAsprintf(buf, ,vgamem_mb=%u, video-vgamem / 1024); } + +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) +video-heads 0) { +virBufferAsprintf(buf, ,max_outputs=%u, video-heads); +} Looks good to me. I would add a comment here why we're not erroring out, but rahter using the parameter only if supported, maybe also add some VIR_INFO output, but no need to resend it just for that. Let's just wait for QEMU to have this in. If it's in and I missed the info, feel free to remind me about pushing this patch to libvirt. Martin } else if (video-vram ((video-type == VIR_DOMAIN_VIDEO_TYPE_VGA virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) || -- 2.1.0 signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 00/10] Restore code to allow unpriv_sgio for hostdev SCSI generic
On Mon, Jul 06, 2015 at 13:08:28 -0400, John Ferlan wrote: v1 here: http://www.redhat.com/archives/libvir-list/2015-June/msg00814.html Changes since v1: - Add doc patch 1 to indicate that this feature may only be supported by certain kernels - Adjust former patch 1 to add call to qemuIsSharedHostdev from qemuSetUnprivSGIO - Insert patches 7 8 which essentially refactor qemuSetUnprivSGIO a bit. There should be no functional difference - Patch 9 is now a much slimmer former patch 6 The end result is that 'generically speaking' if any kernel supports setting the unprivileged SGIO feature, then these patches provide the capability to do so. Although as pointed out in the review of v1 only one specific downstream kernel supports the feature, that doesn't mean other distros couldn't add support in the same manner. So rather than just remove all traces from libvirt completely, it seems it would be reasonable to keep the checks in place and if a kernel then decides to add support this code exists to assist. Well, I'm not going to insist that we revert the existing code since it's possible that the feature might actually make it into the upstream linux kernel eventually. Until it's upstream I don't think though we should add support (even if we document that it will not work) for stuff that is not upstream since the design of the upstream interface might then differ, which will make us carry two implementations. Since there's already existing code that touches the kernel interface for unpriv_sgio, actually exposing the support will then require us to carry that part instead of changing it to the actual upstream impl. If a hypothetical downstream distro would add kernel patches to add the feature, they might as well as carry the downstream libvirt patches too. NACK series until upstream kernel support is present. (Some of the cleanup patches may be worth taking until the kernel issue gets settled though.) Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 0/4] virt-aa-helper fixes
This patch series includes a new version for the trailing slash fix, but also includes other fixes to get virt-sandbox run nicely with apparmor. Thus only one patch has v2 ;) Cédric Bosdonnat (4): virt-aa-helper: fix rules for paths with trailing slash Get more libvirt errors from virt-aa-helper virt-aa-helper: rename ctl-hvm to ctl-os virt-aa-helper: add DomainGuest to mockup caps src/security/security_apparmor.c | 4 src/security/virt-aa-helper.c| 38 ++ tests/virt-aa-helper-test| 3 --- 3 files changed, 38 insertions(+), 7 deletions(-) -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 2/4] Get more libvirt errors from virt-aa-helper
Initializing libvirt log in virt-aa-helper and getting it to output libvirt log to stderr. This will help debugging problems happening in libvirt functions called from within virt-aa-helper --- src/security/security_apparmor.c | 4 src/security/virt-aa-helper.c| 4 2 files changed, 8 insertions(+) diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index 4134a17..16b8f87 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -196,6 +196,10 @@ load_profile(virSecurityManagerPtr mgr, } } +virCommandAddEnvFormat(cmd, + LIBVIRT_LOG_OUTPUTS=%d:stderr, + virLogGetDefaultPriority()); + virCommandSetInputBuffer(cmd, xml); rc = virCommandRun(cmd, NULL); diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 9e18343..3d57431 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -41,6 +41,7 @@ #include virbuffer.h #include viralloc.h #include vircommand.h +#include virlog.h #include security_driver.h #include security_apparmor.h @@ -1266,6 +1267,9 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } +/* Initialize the log system */ +virLogSetFromEnv(); + /* clear the environment */ environ = NULL; if (setenv(PATH, /sbin:/usr/sbin, 1) != 0) -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RESEND] Added support for portable-rpcgen from portablexdr library
On Mon, Jul 06, 2015 at 10:40:28AM +0300, Pavel Fedin wrote: This patch allows to build libvirt natively under MinGW/MSYS using portablexdr library. An updated version of portablexdr with fixed bugs is available as part of MSYS2 project. Signed-off-by: Pavel Fedin p.fe...@samsung.com --- configure.ac | 2 +- src/lxc/lxc_monitor_protocol.x | 2 +- src/rpc/genprotocol.pl | 5 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index aed0934..547a405 100644 --- a/configure.ac +++ b/configure.ac @@ -397,7 +397,7 @@ AM_CONDITIONAL([HAVE_LIBTASN1], [test x$ac_cv_header_libtasn1_h = xyes]) AC_CHECK_LIB([intl],[gettext],[]) dnl Do we have rpcgen? -AC_PATH_PROG([RPCGEN], [rpcgen], [no]) +AC_PATH_PROGS([RPCGEN], [rpcgen portable-rpcgen], [no]) AM_CONDITIONAL([HAVE_RPCGEN], [test x$ac_cv_path_RPCGEN != xno]) dnl Is this GLIBC's buggy rpcgen? AM_CONDITIONAL([HAVE_GLIBC_RPCGEN], diff --git a/src/lxc/lxc_monitor_protocol.x b/src/lxc/lxc_monitor_protocol.x index 3b66af5..205d7c2 100644 --- a/src/lxc/lxc_monitor_protocol.x +++ b/src/lxc/lxc_monitor_protocol.x @@ -30,7 +30,7 @@ enum virLXCMonitorExitStatus { }; struct virLXCMonitorExitEventMsg { -enum virLXCMonitorExitStatus status; +virLXCMonitorExitStatus status; I don't think we should use enums at all in the protocol specification. It should be unsigned int and the change should be made separately. Is this hunk here because portable-rpcgen has problems with enum being declared there? If we leave it here and just remove the 'enum' keyword, then we need to also adjust I see you Cc'd Eric, so I'd leave him some space to object, but unless that happens, the patch looks fine to me without this particular hunk. Martin }; struct virLXCMonitorInitEventMsg { diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl index 6e6d6d4..1ac2507 100755 --- a/src/rpc/genprotocol.pl +++ b/src/rpc/genprotocol.pl @@ -38,7 +38,10 @@ my $target = shift; unlink $target; -open RPCGEN, -|, $rpcgen, $mode, $xdrdef +if ($rpcgen =~ /portable-rpcgen/) { +$rpcgen = $rpcgen -o -; +} +open RPCGEN, -|, $rpcgen $mode $xdrdef or die cannot run $rpcgen $mode $xdrdef: $!; open TARGET, $target or die cannot create $target: $!; -- 1.9.5.msysgit.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/4] virt-aa-helper: fix rules for paths with trailing slash
Rules generated for a path like '/' were having '//' which isn't correct for apparmor. Make virt-aa-helper smarter to avoid these. --- src/security/virt-aa-helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 13f8a6a..9e18343 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -795,6 +795,9 @@ vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool recursi goto cleanup; } +if (tmp[strlen(tmp) - 1] == '/') +tmp[strlen(tmp) - 1] = '\0'; + virBufferAsprintf(buf, \%s%s\ %s,\n, tmp, recursive ? /** : , perms); if (readonly) { virBufferAddLit(buf, # don't audit writes to readonly files\n); -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 4/4] virt-aa-helper: add DomainGuest to mockup caps
With commit 3f9868a virt-aa-helper stopped working due to missing DomainGuest in the caps. The test with -c without arch also needs to be removed since the new capabilities code uses the host arch when none is provided. --- src/security/virt-aa-helper.c | 25 - tests/virt-aa-helper-test | 3 --- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index f94f337..cf729e9 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -73,6 +73,7 @@ typedef struct { virDomainDefPtr def;/* VM definition */ virCapsPtr caps;/* VM capabilities */ virDomainXMLOptionPtr xmlopt; /* XML parser data */ +char *hvm; /* type of hypervisor (eg qemu, xen, lxc) */ char *os; /* type of os (eg hvm, xen, exe) */ virArch arch; /* machine architecture */ char *newfile; /* newly added file */ @@ -89,6 +90,7 @@ vahDeinit(vahControl * ctl) virObjectUnref(ctl-caps); virObjectUnref(ctl-xmlopt); VIR_FREE(ctl-files); +VIR_FREE(ctl-hvm); VIR_FREE(ctl-os); VIR_FREE(ctl-newfile); @@ -641,6 +643,7 @@ verify_xpath_context(xmlXPathContextPtr ctxt) /* * Parse the xml we received to fill in the following: + * ctl-hvm * ctl-os * ctl-arch * @@ -668,6 +671,11 @@ caps_mockup(vahControl * ctl, const char *xmlStr) if (verify_xpath_context(ctxt) != 0) goto cleanup; +ctl-hvm = virXPathString(string(./@type), ctxt); +if (!ctl-hvm) { +vah_error(ctl, 0, _(domain type is not defined)); +goto cleanup; +} ctl-os = virXPathString(string(./os/type[1]), ctxt); if (!ctl-os) { vah_error(ctl, 0, _(os.type is not defined)); @@ -694,7 +702,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr) static int get_definition(vahControl * ctl, const char *xmlStr) { -int rc = -1, ostype; +int rc = -1, ostype, hvmtype; virCapsGuestPtr guest; /* this is freed when caps is freed */ /* @@ -730,6 +738,21 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } +if ((hvmtype = virDomainVirtTypeFromString(ctl-hvm)) 0) { +vah_error(ctl, 0, _(unknown HVM type)); +goto exit; +} + +if (virCapabilitiesAddGuestDomain(guest, + hvmtype, + NULL, + NULL, + 0, + NULL) == NULL) { +vah_error(ctl, 0, _(could not allocate memory)); +goto exit; +} + ctl-def = virDomainDefParseString(xmlStr, ctl-caps, ctl-xmlopt, VIR_DOMAIN_DEF_PARSE_INACTIVE); diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test index 96471ff..caf2f97 100755 --- a/tests/virt-aa-helper-test +++ b/tests/virt-aa-helper-test @@ -194,9 +194,6 @@ testme 1 -c with malformed xml -c -u $valid_uuid $test_xml sed -e s,###UUID###,$uuid,g -e s,###DISK###,$disk1,g -e s,type arch='x86_64' machine='pc'hvm/type,,g $template_xml $test_xml testme 1 -c with no os.type -c -u $valid_uuid $test_xml -sed -e s,###UUID###,$uuid,g -e s,###DISK###,$disk1,g -e s,type arch='x86_64' machine='pc'hvm/type,typehvm/type,g $template_xml $test_xml -testme 1 -c with no architecture -c -u $valid_uuid $test_xml - sed -e s,###UUID###,$uuid,g -e s,###DISK###,$disk1,g -e s,hvm/type,hvm_invalid/type,g $template_xml $test_xml testme 1 -c with invalid hvm -c -u $valid_uuid $test_xml -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 3/4] virt-aa-helper: rename ctl-hvm to ctl-os
ctl-hvm contains os.type string value, change the name to reflect it. --- src/security/virt-aa-helper.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 3d57431..f94f337 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -73,7 +73,7 @@ typedef struct { virDomainDefPtr def;/* VM definition */ virCapsPtr caps;/* VM capabilities */ virDomainXMLOptionPtr xmlopt; /* XML parser data */ -char *hvm; /* type of hypervisor (eg hvm, xen) */ +char *os; /* type of os (eg hvm, xen, exe) */ virArch arch; /* machine architecture */ char *newfile; /* newly added file */ bool append;/* append to .files instead of rewrite */ @@ -89,7 +89,7 @@ vahDeinit(vahControl * ctl) virObjectUnref(ctl-caps); virObjectUnref(ctl-xmlopt); VIR_FREE(ctl-files); -VIR_FREE(ctl-hvm); +VIR_FREE(ctl-os); VIR_FREE(ctl-newfile); return 0; @@ -641,7 +641,7 @@ verify_xpath_context(xmlXPathContextPtr ctxt) /* * Parse the xml we received to fill in the following: - * ctl-hvm + * ctl-os * ctl-arch * * These are suitable for setting up a virCapsPtr @@ -668,8 +668,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr) if (verify_xpath_context(ctxt) != 0) goto cleanup; -ctl-hvm = virXPathString(string(./os/type[1]), ctxt); -if (!ctl-hvm) { +ctl-os = virXPathString(string(./os/type[1]), ctxt); +if (!ctl-os) { vah_error(ctl, 0, _(os.type is not defined)); goto cleanup; } @@ -714,7 +714,7 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } -if ((ostype = virDomainOSTypeFromString(ctl-hvm)) 0) { +if ((ostype = virDomainOSTypeFromString(ctl-os)) 0) { vah_error(ctl, 0, _(unknown OS type)); goto exit; } -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib PATCHv4 4/7] gobject: Add API to query connection interfaces
On Wed, Jul 01, 2015 at 09:40:48PM +0100, Zeeshan Ali (Khattak) wrote: Add API to query network interfaces from a connection. --- libvirt-gobject/libvirt-gobject-connection.c | 265 +++ libvirt-gobject/libvirt-gobject-connection.h | 13 +- libvirt-gobject/libvirt-gobject.sym | 7 + 3 files changed, 283 insertions(+), 2 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index f7a6066..47b6861 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -44,6 +44,7 @@ struct _GVirConnectionPrivate GHashTable *domains; GHashTable *pools; +GHashTable *interfaces; }; G_DEFINE_TYPE(GVirConnection, gvir_connection, G_TYPE_OBJECT); @@ -252,6 +253,10 @@ static void gvir_connection_init(GVirConnection *conn) g_str_equal, NULL, g_object_unref); +priv-interfaces = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); } @@ -662,6 +667,11 @@ void gvir_connection_close(GVirConnection *conn) priv-pools = NULL; } +if (priv-interfaces) { +g_hash_table_unref(priv-interfaces); +priv-interfaces = NULL; +} + if (priv-conn) { virConnectDomainEventDeregister(priv-conn, domain_event_cb); virConnectClose(priv-conn); @@ -1431,6 +1441,261 @@ GVirDomain *gvir_connection_start_domain(GVirConnection *conn, } /** + * gvir_connection_fetch_interfaces: + * @conn: a #GVirConnection + * @cancellable: (allow-none)(transfer none): cancellation object + * @err: return location for any errors + * + * Use this method to fetch information on all network interfaces s/on/about ? + * managed by connection @conn on host machine. Use + * #gvir_connection_get_interfaces or #gvir_connection_get_interface after + * wards to query the fetched interfaces. 'afterwards' is a single word + * + * Return value: %TRUE on success, %FALSE otherwise and @err is set. + */ +gboolean gvir_connection_fetch_interfaces(GVirConnection *conn, + GCancellable *cancellable, + GError **err) +{ +GVirConnectionPrivate *priv; +GHashTable *interfaces; +virInterfacePtr *ifaces = NULL; +gint ninterfaces = 0; +gboolean ret = FALSE; +gint i; +virConnectPtr vconn = NULL; + +g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); +g_return_val_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable), + FALSE); +g_return_val_if_fail((err == NULL) || (*err == NULL), FALSE); + +priv = conn-priv; +g_mutex_lock(priv-lock); +if (!priv-conn) { +g_set_error_literal(err, GVIR_CONNECTION_ERROR, +0, +_(Connection is not open)); +g_mutex_unlock(priv-lock); +goto cleanup; +} +vconn = priv-conn; +/* Stop another thread closing the connection just at the minute */ +virConnectRef(vconn); +g_mutex_unlock(priv-lock); + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +ninterfaces = virConnectListAllInterfaces(vconn, ifaces, 0); +if (ninterfaces 0) { +gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + _(Failed to fetch list of interfaces)); +goto cleanup; +} + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +interfaces = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); + +for (i = 0 ; i ninterfaces; i++) { +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +GVirInterface *iface; + I'd put this before the cancellable check. +iface = GVIR_INTERFACE(g_object_new(GVIR_TYPE_INTERFACE, + handle, ifaces[i], + NULL)); + parameter alignment is off here +g_hash_table_insert(interfaces, +(gpointer)gvir_interface_get_name(iface), +iface); +} + +g_mutex_lock(priv-lock); +if (priv-interfaces) +g_hash_table_unref(priv-interfaces); +priv-interfaces = interfaces; +g_mutex_unlock(priv-lock); + +ret = TRUE; + +cleanup: +if (ninterfaces 0) { +
Re: [libvirt] [PATCH v3 1/3] Introduce QEMU_CAPS_ARM_VIRT_PCI
Hello! Is there a way how we could detect this according to the actual presence of the PCI bus for the ARM machine? A certain device type that can be queried rather than relying on a version check. I looked at the code you suggested. As far as i could understand, it actually parses an output of qemu-system-blah -device ? plus some extras. And this command lists all devices that this qemu version knows, and not only what can be attached to a particular machine. I browsed through the history of qemu patches. Actually, gpex-pcihost device was implemented together with adding it to 'virt' machine. So, i could query for this flag and count it as capability. But - it only says that qemu knows this device in principle. It does not say that this device is really a part of virt machine. Will it be acceptable ? Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib PATCHv5 2/7] gobject: Plug 2 virConnect leaks
A virConnect reference is leaked in error cases. This patch moves the unref after the label we jump to on errors, to avoid this leak. --- libvirt-gobject/libvirt-gobject-connection.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index e088427..02eef7b 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -748,7 +748,6 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, if (priv-domains) g_hash_table_unref(priv-domains); priv-domains = doms; -virConnectClose(vconn); g_mutex_unlock(priv-lock); ret = TRUE; @@ -759,6 +758,8 @@ cleanup: virDomainFree(domains[i]); free(domains); } +if (vconn != NULL) +virConnectClose(vconn); return ret; } @@ -835,7 +836,6 @@ gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn, if (priv-pools) g_hash_table_unref(priv-pools); priv-pools = pools; -virConnectClose(vconn); g_mutex_unlock(priv-lock); ret = TRUE; @@ -846,6 +846,8 @@ cleanup: virStoragePoolFree(vpools[i]); free(vpools); } +if (vconn != NULL) +virConnectClose(vconn); return ret; } -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib PATCHv5 5/7] gobject: Add API to query connection networks
Add API to query networks from a connection. --- libvirt-gobject/libvirt-gobject-connection.c | 262 +++ libvirt-gobject/libvirt-gobject-connection.h | 13 +- libvirt-gobject/libvirt-gobject.sym | 6 + 3 files changed, 279 insertions(+), 2 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index 7d28178..9e7bb68 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -45,6 +45,7 @@ struct _GVirConnectionPrivate GHashTable *domains; GHashTable *pools; GHashTable *interfaces; +GHashTable *networks; }; G_DEFINE_TYPE(GVirConnection, gvir_connection, G_TYPE_OBJECT); @@ -257,6 +258,10 @@ static void gvir_connection_init(GVirConnection *conn) g_str_equal, NULL, g_object_unref); +priv-networks = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); } @@ -678,6 +683,11 @@ void gvir_connection_close(GVirConnection *conn) priv-interfaces = NULL; } +if (priv-networks) { +g_hash_table_unref(priv-networks); +priv-networks = NULL; +} + if (priv-conn) { virConnectDomainEventDeregister(priv-conn, domain_event_cb); virConnectClose(priv-conn); @@ -1713,6 +1723,258 @@ GVirInterface *gvir_connection_find_interface_by_mac(GVirConnection *conn, } /** + * gvir_connection_fetch_networks: + * @conn: a #GVirConnection + * @cancellable: (allow-none)(transfer none): cancellation object + */ +gboolean gvir_connection_fetch_networks(GVirConnection *conn, +GCancellable *cancellable, +GError **err) +{ +GVirConnectionPrivate *priv; +GHashTable *networks; +virNetworkPtr *vnetworks = NULL; +gint nnetworks = 0; +gboolean ret = FALSE; +gint i; +virConnectPtr vconn = NULL; + +g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); +g_return_val_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable), + FALSE); +g_return_val_if_fail((err == NULL) || (*err == NULL), FALSE); + +priv = conn-priv; +g_mutex_lock(priv-lock); +if (!priv-conn) { +g_set_error_literal(err, GVIR_CONNECTION_ERROR, +0, +_(Connection is not open)); +g_mutex_unlock(priv-lock); +goto cleanup; +} +vconn = priv-conn; +/* Stop another thread closing the connection just at the minute */ +virConnectRef(vconn); +g_mutex_unlock(priv-lock); + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +nnetworks = virConnectListAllNetworks(vconn, vnetworks, 0); +if (nnetworks 0) { +gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + _(Failed to fetch list of networks)); +goto cleanup; +} + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +networks = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); + +for (i = 0 ; i nnetworks; i++) { +GVirNetwork *network; + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +network = GVIR_NETWORK(g_object_new(GVIR_TYPE_NETWORK, +handle, vnetworks[i], +NULL)); +g_hash_table_insert(networks, +(gpointer)gvir_network_get_uuid(network), +network); +} + +g_mutex_lock(priv-lock); +if (priv-networks) +g_hash_table_unref(priv-networks); +priv-networks = networks; +g_mutex_unlock(priv-lock); + +ret = TRUE; + +cleanup: +if (nnetworks 0) { +for (i = 0 ; i nnetworks; i++) +virNetworkFree(vnetworks[i]); +free(vnetworks); +} +if (vconn != NULL) +virConnectClose(vconn); +return ret; +} + +static void +gvir_connection_fetch_networks_helper(GTask *task, + gpointer object, + gpointer task_data G_GNUC_UNUSED, + GCancellable *cancellable) +{ +GVirConnection *conn = GVIR_CONNECTION(object); +GError *err = NULL; + +if (!gvir_connection_fetch_networks(conn, cancellable, err)) +g_task_return_error(task, err); +else +g_task_return_boolean(task, TRUE); +} + +/** + *
[libvirt] [libvirt-glib PATCHv5 4/7] gobject: Add API to query connection interfaces
Add API to query network interfaces from a connection. --- libvirt-gobject/libvirt-gobject-connection.c | 270 +++ libvirt-gobject/libvirt-gobject-connection.h | 13 +- libvirt-gobject/libvirt-gobject.sym | 7 + 3 files changed, 288 insertions(+), 2 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index 5b3a7bc..7d28178 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -44,6 +44,7 @@ struct _GVirConnectionPrivate GHashTable *domains; GHashTable *pools; +GHashTable *interfaces; }; G_DEFINE_TYPE(GVirConnection, gvir_connection, G_TYPE_OBJECT); @@ -252,6 +253,10 @@ static void gvir_connection_init(GVirConnection *conn) g_str_equal, NULL, g_object_unref); +priv-interfaces = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); } @@ -668,6 +673,11 @@ void gvir_connection_close(GVirConnection *conn) priv-pools = NULL; } +if (priv-interfaces) { +g_hash_table_unref(priv-interfaces); +priv-interfaces = NULL; +} + if (priv-conn) { virConnectDomainEventDeregister(priv-conn, domain_event_cb); virConnectClose(priv-conn); @@ -1443,6 +1453,266 @@ GVirDomain *gvir_connection_start_domain(GVirConnection *conn, } /** + * gvir_connection_fetch_interfaces: + * @conn: a #GVirConnection + * @cancellable: (allow-none)(transfer none): cancellation object + * @err: return location for any errors + * + * Use this method to fetch information on all network interfaces + * managed by connection @conn on host machine. Use + * #gvir_connection_get_interfaces or #gvir_connection_get_interface afterwards + * to query the fetched interfaces. + * + * Return value: %TRUE on success, %FALSE otherwise and @err is set. + */ +gboolean gvir_connection_fetch_interfaces(GVirConnection *conn, + GCancellable *cancellable, + GError **err) +{ +GVirConnectionPrivate *priv; +GHashTable *interfaces; +virInterfacePtr *ifaces = NULL; +gint ninterfaces = 0; +gboolean ret = FALSE; +gint i; +virConnectPtr vconn = NULL; + +g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); +g_return_val_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable), + FALSE); +g_return_val_if_fail((err == NULL) || (*err == NULL), FALSE); + +priv = conn-priv; +g_mutex_lock(priv-lock); +if (!priv-conn) { +g_set_error_literal(err, GVIR_CONNECTION_ERROR, +0, +_(Connection is not open)); +g_mutex_unlock(priv-lock); +goto cleanup; +} +vconn = priv-conn; +/* Stop another thread closing the connection just at the minute */ +virConnectRef(vconn); +g_mutex_unlock(priv-lock); + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +ninterfaces = virConnectListAllInterfaces(vconn, ifaces, 0); +if (ninterfaces 0) { +gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + _(Failed to fetch list of interfaces)); +goto cleanup; +} + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +interfaces = g_hash_table_new_full(g_str_hash, + g_str_equal, + NULL, + g_object_unref); + +for (i = 0 ; i ninterfaces; i++) { +GVirInterface *iface; + +if (g_cancellable_set_error_if_cancelled(cancellable, err)) +goto cleanup; + +iface = GVIR_INTERFACE(g_object_new(GVIR_TYPE_INTERFACE, +handle, ifaces[i], +NULL)); + +g_hash_table_insert(interfaces, +(gpointer)gvir_interface_get_name(iface), +iface); +} + +g_mutex_lock(priv-lock); +if (priv-interfaces) +g_hash_table_unref(priv-interfaces); +priv-interfaces = interfaces; +g_mutex_unlock(priv-lock); + +ret = TRUE; + +cleanup: +if (ninterfaces 0) { +for (i = 0 ; i ninterfaces; i++) +virInterfaceFree(ifaces[i]); +free(ifaces); +} +if (vconn != NULL) +virConnectClose(vconn); +return ret; +} + +static void +gvir_connection_fetch_interfaces_helper(GTask *task, +gpointer object, +
[libvirt] [libvirt-glib PATCHv5 1/7] gobject: Simplify gvir_connection_list*() implementations
Make use of virConnectListAll* functions to avoid making 4 calls and hence avoid race conditions and complicated code. --- libvirt-gobject/libvirt-gobject-connection.c | 203 --- 1 file changed, 28 insertions(+), 175 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index cf073a5..e088427 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -680,48 +680,6 @@ void gvir_connection_close(GVirConnection *conn) g_signal_emit(conn, signals[VIR_CONNECTION_CLOSED], 0); } -typedef gint (* CountFunction) (virConnectPtr vconn); -typedef gint (* ListFunction) (virConnectPtr vconn, gchar **lst, gint max); - -static gchar ** fetch_list(virConnectPtr vconn, - const char *name, - CountFunction count_func, - ListFunction list_func, - GCancellable *cancellable, - gint *length, - GError **err) -{ -gchar **lst = NULL; -gint n = 0; - -if ((n = count_func(vconn)) 0) { -gvir_set_error(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to count %s), name); -goto error; -} - -if (n) { -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto error; - -lst = g_new0(gchar *, n); -if ((n = list_func(vconn, lst, n)) 0) { -gvir_set_error(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to list %s %d), name, n); -goto error; -} -} - -*length = n; -return lst; - -error: -g_free(lst); -return NULL; -} - /** * gvir_connection_fetch_domains: * @conn: a #GVirConnection @@ -733,14 +691,11 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, { GVirConnectionPrivate *priv; GHashTable *doms; -gchar **inactive = NULL; -gint ninactive = 0; -gint *active = NULL; -gint nactive = 0; +virDomainPtr *domains = NULL; +gint ndomains = 0; gboolean ret = FALSE; gint i; virConnectPtr vconn = NULL; -GError *lerr = NULL; g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); g_return_val_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable), @@ -761,81 +716,28 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, virConnectRef(vconn); g_mutex_unlock(priv-lock); -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto cleanup; - -if ((nactive = virConnectNumOfDomains(vconn)) 0) { -gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to count domains)); +ndomains = virConnectListAllDomains(vconn, domains, 0); +if (ndomains 0) { +gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + _(Failed to fetch list of domains)); goto cleanup; } -if (nactive) { -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto cleanup; - -active = g_new(gint, nactive); -if ((nactive = virConnectListDomains(vconn, active, nactive)) 0) { -gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to list domains)); -goto cleanup; -} -} if (g_cancellable_set_error_if_cancelled(cancellable, err)) goto cleanup; -inactive = fetch_list(vconn, - Domains, - virConnectNumOfDefinedDomains, - virConnectListDefinedDomains, - cancellable, - ninactive, - lerr); -if (lerr) { -g_propagate_error(err, lerr); -lerr = NULL; -goto cleanup; -} - doms = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); -for (i = 0 ; i nactive ; i++) { -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto cleanup; - -virDomainPtr vdom = virDomainLookupByID(vconn, active[i]); +for (i = 0 ; i ndomains; i++) { GVirDomain *dom; -if (!vdom) -continue; dom = GVIR_DOMAIN(g_object_new(GVIR_TYPE_DOMAIN, - handle, vdom, + handle, domains[i], NULL)); -virDomainFree(vdom); - -g_hash_table_insert(doms, -(gpointer)gvir_domain_get_uuid(dom), -dom); -} - -
[libvirt] [libvirt-glib PATCHv5 3/7] gobject: Port GVirConnection to GTask
GSimpleAsyncResult has been deprecated in favour of GTask and with latest glib headers, we get tons of warnings about use of deprecated API. This patch ports the GVirConnection class to GTask. --- libvirt-gobject/libvirt-gobject-connection.c | 280 +-- 1 file changed, 136 insertions(+), 144 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index 02eef7b..5b3a7bc 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -497,17 +497,18 @@ gboolean gvir_connection_open_read_only(GVirConnection *conn, } static void -gvir_connection_open_helper(GSimpleAsyncResult *res, -GObject *object, +gvir_connection_open_helper(GTask *task, +gpointer object, +gpointer task_data G_GNUC_UNUSED, GCancellable *cancellable) { GVirConnection *conn = GVIR_CONNECTION(object); GError *err = NULL; -if (!gvir_connection_open(conn, cancellable, err)) { -g_simple_async_result_set_from_error(res, err); -g_error_free(err); -} +if (!gvir_connection_open(conn, cancellable, err)) +g_task_return_error(task, err); +else +g_task_return_boolean(task, TRUE); } @@ -523,20 +524,20 @@ void gvir_connection_open_async(GVirConnection *conn, GAsyncReadyCallback callback, gpointer user_data) { -GSimpleAsyncResult *res; +GTask *task; g_return_if_fail(GVIR_IS_CONNECTION(conn)); g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable)); -res = g_simple_async_result_new(G_OBJECT(conn), -callback, -user_data, -gvir_connection_open_async); -g_simple_async_result_run_in_thread(res, -gvir_connection_open_helper, -G_PRIORITY_DEFAULT, -cancellable); -g_object_unref(res); +task = g_task_new(G_OBJECT(conn), + cancellable, + callback, + user_data); +g_task_set_source_tag(task, + gvir_connection_open_async); +g_task_run_in_thread(task, + gvir_connection_open_helper); +g_object_unref(task); } @@ -550,28 +551,28 @@ gboolean gvir_connection_open_finish(GVirConnection *conn, GError **err) { g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); -g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(conn), - gvir_connection_open_async), +g_return_val_if_fail(g_task_is_valid(result, G_OBJECT(conn)), + FALSE); +g_return_val_if_fail(g_task_get_source_tag(G_TASK(result)) == + gvir_connection_open_async, FALSE); -if (g_simple_async_result_propagate_error(G_SIMPLE_ASYNC_RESULT(result), err)) -return FALSE; - -return TRUE; +return g_task_propagate_boolean(G_TASK(result), err); } static void -gvir_connection_open_read_only_helper(GSimpleAsyncResult *res, -GObject *object, -GCancellable *cancellable) +gvir_connection_open_read_only_helper(GTask *task, + gpointer object, + gpointer task_data G_GNUC_UNUSED, + GCancellable *cancellable) { GVirConnection *conn = GVIR_CONNECTION(object); GError *err = NULL; -if (!gvir_connection_open_read_only(conn, cancellable, err)) { -g_simple_async_result_set_from_error(res, err); -g_error_free(err); -} +if (!gvir_connection_open_read_only(conn, cancellable, err)) +g_task_return_error(task, err); +else +g_task_return_boolean(task, TRUE); } @@ -587,20 +588,20 @@ void gvir_connection_open_read_only_async(GVirConnection *conn, GAsyncReadyCallback callback, gpointer user_data) { -GSimpleAsyncResult *res; +GTask *task; g_return_if_fail(GVIR_IS_CONNECTION(conn)); g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable)); -res = g_simple_async_result_new(G_OBJECT(conn), -callback, -user_data, -gvir_connection_open_read_only_async); -g_simple_async_result_run_in_thread(res, -gvir_connection_open_read_only_helper, -
Re: [libvirt] [PATCH RESEND] Added support for portable-rpcgen from portablexdr library
Hello! Could you split that hunk into another patch and also fix it in lxc_monitor_protocol-structs so that make syntax-check doesn't bother us? No problem, i will do it. If i have further questions, i'll ask them tomorrow because i'm in 40 minutes apart from leaving the office today. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib PATCHv5 6/7] gobject: Add wrapper for virNetworkDHCPLease
--- libvirt-gobject/Makefile.am| 5 +- .../libvirt-gobject-network-dhcp-lease-private.h | 34 +++ .../libvirt-gobject-network-dhcp-lease.c | 252 + .../libvirt-gobject-network-dhcp-lease.h | 85 +++ libvirt-gobject/libvirt-gobject.h | 1 + libvirt-gobject/libvirt-gobject.sym| 13 ++ 6 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h create mode 100644 libvirt-gobject/libvirt-gobject-network-dhcp-lease.c create mode 100644 libvirt-gobject/libvirt-gobject-network-dhcp-lease.h diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am index 7163c7d..8464f04 100644 --- a/libvirt-gobject/Makefile.am +++ b/libvirt-gobject/Makefile.am @@ -13,6 +13,7 @@ GOBJECT_HEADER_FILES = \ libvirt-gobject-domain.h \ libvirt-gobject-interface.h \ libvirt-gobject-network.h \ + libvirt-gobject-network-dhcp-lease.h \ libvirt-gobject-network-filter.h \ libvirt-gobject-node-device.h \ libvirt-gobject-secret.h \ @@ -22,7 +23,8 @@ GOBJECT_HEADER_FILES = \ libvirt-gobject-connection.h \ libvirt-gobject-manager.h noinst_HEADERS = \ - libvirt-gobject-storage-pool-private.h + libvirt-gobject-storage-pool-private.h \ + libvirt-gobject-network-dhcp-lease-private.h GOBJECT_SOURCE_FILES = \ libvirt-gobject-main.c \ libvirt-gobject-domain-snapshot.c \ @@ -32,6 +34,7 @@ GOBJECT_SOURCE_FILES = \ libvirt-gobject-domain.c \ libvirt-gobject-interface.c \ libvirt-gobject-network.c \ + libvirt-gobject-network-dhcp-lease.c \ libvirt-gobject-network-filter.c \ libvirt-gobject-node-device.c \ libvirt-gobject-secret.c \ diff --git a/libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h b/libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h new file mode 100644 index 000..eaf6c2f --- /dev/null +++ b/libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h @@ -0,0 +1,34 @@ +/* + * libvirt-gobject-network-dhcp-lease-private.h: libvirt gobject integration + * + * Copyright (C) 2010-2011 Red Hat, Inc. + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * http://www.gnu.org/licenses/. + * + * Authors: Zeeshan Ali (Khattak) zeesha...@gnome.org + * Daniel P. Berrange berra...@redhat.com + */ + +#ifndef __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_PRIVATE_H__ +#define __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_PRIVATE_H__ + +G_BEGIN_DECLS + +GVirNetworkDHCPLease *gvir_network_dhcp_lease_new(virNetworkDHCPLeasePtr handle); + +G_END_DECLS + +#endif /* __LIBVIRT_GOBJECT_NETWORK_DHCP_LEASE_PRIVATE_H__ */ diff --git a/libvirt-gobject/libvirt-gobject-network-dhcp-lease.c b/libvirt-gobject/libvirt-gobject-network-dhcp-lease.c new file mode 100644 index 000..6ac3c14 --- /dev/null +++ b/libvirt-gobject/libvirt-gobject-network-dhcp-lease.c @@ -0,0 +1,252 @@ +/* + * libvirt-gobject-network-dhcp-lease.c: libvirt glib integration + * + * Copyright (C) 2008 Daniel P. Berrange + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * http://www.gnu.org/licenses/. + * + * Authors: Zeeshan Ali (Khattak) zeesha...@gnome.org + * Daniel P. Berrange berra...@redhat.com + */ + +#include config.h + +#include
[libvirt] [PATCH v2 0/1] vz: assign static IPs and default gateways for network adapter
fix avoid_if_before_free warnings for VIR_FREE calls fix found diagnostic without % warnings for virReportError calls use virAsprintf instead of virBufferAsprintf set default gateway only if static ip is present write inet family to log in case of unsupported gateway Mikhail Feoktistov (1): vz: assign static IPs and default gateways for network adapter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 1/1] vz: assign static IPs and default gateways for network adapter
We support only one IPv4 and one IPv6 default gateway. If static IPs are not present in instance config, then we switch on DHCP for this adapter. PrlVmDevNet_SetAutoApply to makes necessary settings within guest OS In linux case it creates network startup scripts /etc/sysconfig/network-scripts/ifcfg-ethN and fills it with necessary parameters. --- src/vz/vz_sdk.c | 126 +++ 1 files changed, 126 insertions(+), 0 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 1b66958..1b8298c 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -2762,8 +2762,13 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, PRL_HANDLE sdknet = PRL_INVALID_HANDLE; PRL_HANDLE vnet = PRL_INVALID_HANDLE; PRL_HANDLE job = PRL_INVALID_HANDLE; +PRL_HANDLE addrlist = PRL_INVALID_HANDLE; +size_t i; int ret = -1; char macstr[PRL_MAC_STRING_BUFNAME]; +char *addrstr = NULL; +bool ipv6present = false; +bool ipv4present = false; if (prlsdkCheckNetUnsupportedParams(net) 0) return -1; @@ -2788,6 +2793,125 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, pret = PrlVmDevNet_SetMacAddress(sdknet, macstr); prlsdkCheckRetGoto(pret, cleanup); +pret = PrlApi_CreateStringsList(addrlist); +prlsdkCheckRetGoto(pret, cleanup); + +for (i = 0; i net-nips; i++) { +char *tmpstr; + +if (AF_INET == VIR_SOCKET_ADDR_FAMILY(net-ips[i]-address)) +ipv4present = true; +else if (AF_INET6 == VIR_SOCKET_ADDR_FAMILY(net-ips[i]-address)) +ipv6present = true; +else +continue; + +if (!(tmpstr = virSocketAddrFormat(net-ips[i]-address))) +goto cleanup; + +if (virAsprintf(addrstr, %s/%d, tmpstr, net-ips[i]-prefix) 0) { +VIR_FREE(tmpstr); +goto cleanup; +} + +VIR_FREE(tmpstr); +pret = PrlStrList_AddItem(addrlist, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +VIR_FREE(addrstr); +} + +if (ipv4present || ipv6present) { +pret = PrlVmDevNet_SetNetAddresses(sdknet, addrlist); +prlsdkCheckRetGoto(pret, cleanup); +} + +pret = PrlVmDevNet_SetConfigureWithDhcp(sdknet, !ipv4present); +prlsdkCheckRetGoto(pret, cleanup); + +pret = PrlVmDevNet_SetConfigureWithDhcpIPv6(sdknet, !ipv6present); +prlsdkCheckRetGoto(pret, cleanup); + +pret = PrlVmDevNet_SetAutoApply(sdknet, true); +prlsdkCheckRetGoto(pret, cleanup); + +if (net-nroutes) { +bool alreadySetIPv4Gateway = false; +bool alreadySetIPv6Gateway = false; + +for (i = 0; i net-nroutes; i++) { +virSocketAddrPtr addrdst, gateway; +virSocketAddr zero; + +addrdst = virNetworkRouteDefGetAddress(net-routes[i]); +gateway = virNetworkRouteDefGetGateway(net-routes[i]); + +ignore_value(virSocketAddrParse(zero, +(VIR_SOCKET_ADDR_IS_FAMILY(addrdst, AF_INET) + ? VIR_SOCKET_ADDR_IPV4_ALL + : VIR_SOCKET_ADDR_IPV6_ALL), +VIR_SOCKET_ADDR_FAMILY(addrdst))); + +if (!virSocketAddrEqual(addrdst, zero)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Support only default gateway)); +goto cleanup; +} + +switch (VIR_SOCKET_ADDR_FAMILY(gateway)) { +case AF_INET: + +if (!ipv4present) +continue; + +if (alreadySetIPv4Gateway) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Support only one IPv4 default gateway)); +goto cleanup; +} + +if (!(addrstr = virSocketAddrFormat(gateway))) +goto cleanup; + +pret = PrlVmDevNet_SetDefaultGateway(sdknet, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +alreadySetIPv4Gateway = true; +break; + +case AF_INET6: + +if (!ipv6present) +continue; + +if (alreadySetIPv6Gateway) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Support only one IPv6 default gateway)); +goto cleanup; +} + +if (!(addrstr = virSocketAddrFormat(gateway))) +goto cleanup; + +pret = PrlVmDevNet_SetDefaultGatewayIPv6(sdknet, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +alreadySetIPv6Gateway = true; +break; + +default: +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Unsupported address family %d +
Re: [libvirt] [PATCH RESEND] Added support for portable-rpcgen from portablexdr library
On Tue, Jul 07, 2015 at 03:04:51PM +0300, Pavel Fedin wrote: Hello! I don't think we should use enums at all in the protocol specification. It should be unsigned int and the change should be made separately. Is this hunk here because portable-rpcgen has problems with enum being declared there? Yes, its parser fails. I have checked throughout the code, there are some other enums in .x files too, but when they are put in structs, they are specified without 'enum' keyword and everything is fine. For example, virnetprotocol.x: --- cut --- struct virNetMessageHeader { unsigned prog; /* Unique ID for the program */ unsigned vers; /* Program version number */ int proc; /* Unique ID for the procedure within the program */ virNetMessageType type; /* Type of message */ unsigned serial;/* Serial number of message. */ virNetMessageStatus status; }; --- cut --- Here virNetMessageType and virNetMessageStatus are enums. Actually i borrowed fix method from here. I see. I'm still a little bit hesitant about that, but that's pre-existing to your patch, so that shouldn't keep us away from that. Could you split that hunk into another patch and also fix it in lxc_monitor_protocol-structs so that make syntax-check doesn't bother us? Thanks, Martin Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] vz: assign static IPs and default gateways for network adapter
send v2 06.07.2015 21:28, Dmitry Guryanov пишет: On 07/01/2015 01:15 PM, Mikhail Feoktistov wrote: We support only one IPv4 and one IPv6 default gateway. If static IPs are not present in instance config, then we switch on DHCP for this adapter. PrlVmDevNet_SetAutoApply to makes necessary settings within guest OS In linux case it creates network startup scripts /etc/sysconfig/network-scripts/ifcfg-ethN and fills it with necessary parameters. --- src/vz/vz_sdk.c | 120 +++ 1 files changed, 120 insertions(+), 0 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f27098c..7d318f8 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -2788,8 +2788,13 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, PRL_HANDLE sdknet = PRL_INVALID_HANDLE; PRL_HANDLE vnet = PRL_INVALID_HANDLE; PRL_HANDLE job = PRL_INVALID_HANDLE; +PRL_HANDLE addrlist = PRL_INVALID_HANDLE; +size_t i; int ret = -1; char macstr[PRL_MAC_STRING_BUFNAME]; +char *addrstr = NULL; +bool ipv6present = false; +bool ipv4present = false; if (prlsdkCheckNetUnsupportedParams(net) 0) return -1; @@ -2814,6 +2819,118 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, pret = PrlVmDevNet_SetMacAddress(sdknet, macstr); prlsdkCheckRetGoto(pret, cleanup); +pret = PrlApi_CreateStringsList(addrlist); +prlsdkCheckRetGoto(pret, cleanup); + +for (i = 0; i net-nips; i++) { +virBuffer buf = VIR_BUFFER_INITIALIZER; +char *tmpstr; + +if (AF_INET == VIR_SOCKET_ADDR_FAMILY(net-ips[i]-address)) +ipv4present = true; +else if (AF_INET6 == VIR_SOCKET_ADDR_FAMILY(net-ips[i]-address)) +ipv6present = true; +else +continue; + +if (!(tmpstr = virSocketAddrFormat(net-ips[i]-address))) +goto cleanup; + +virBufferAsprintf(buf, %s/%d, tmpstr, net-ips[i]-prefix); +VIR_FREE(tmpstr); +if (!(addrstr = virBufferContentAndReset(buf))) +goto cleanup; It's better to use virAsprintf here, since you do string formatting only once. + +pret = PrlStrList_AddItem(addrlist, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +VIR_FREE(addrstr); +addrstr = NULL; VIR_FREE sets the pointer to NULL, you don't need to do it by yourself. Also it's being caught by make syntax-check Could you, please, run it before sending patches? +} + +if (ipv4present || ipv6present) { +pret = PrlVmDevNet_SetNetAddresses(sdknet, addrlist); +prlsdkCheckRetGoto(pret, cleanup); +} + +pret = PrlVmDevNet_SetConfigureWithDhcp(sdknet, !ipv4present); +prlsdkCheckRetGoto(pret, cleanup); + +pret = PrlVmDevNet_SetConfigureWithDhcpIPv6(sdknet, !ipv6present); +prlsdkCheckRetGoto(pret, cleanup); + +pret = PrlVmDevNet_SetAutoApply(sdknet, true); +prlsdkCheckRetGoto(pret, cleanup); + +if (net-nroutes) { As I can remember, it's not possible to set gateway together with DHCP. So I think you should set up gateways before dhcp and only if ipv4present/ipv6present is true. +bool alreadySetIPv4Gateway = false; +bool alreadySetIPv6Gateway = false; + +for (i = 0; i net-nroutes; i++) { +virSocketAddrPtr addrdst, gateway; +virSocketAddr zero; + +addrdst = virNetworkRouteDefGetAddress(net-routes[i]); +gateway = virNetworkRouteDefGetGateway(net-routes[i]); + +ignore_value(virSocketAddrParse(zero, + (VIR_SOCKET_ADDR_IS_FAMILY(addrdst, AF_INET) + ? VIR_SOCKET_ADDR_IPV4_ALL + : VIR_SOCKET_ADDR_IPV6_ALL), + VIR_SOCKET_ADDR_FAMILY(addrdst))); + +if (!virSocketAddrEqual(addrdst, zero)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Support only default gateway)); +goto cleanup; +} + +switch (VIR_SOCKET_ADDR_FAMILY(gateway)) { +case AF_INET: +if (alreadySetIPv4Gateway) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Support only one IPv4 default gateway)); +goto cleanup; +} + +if (!(addrstr = virSocketAddrFormat(gateway))) +goto cleanup; + +pret = PrlVmDevNet_SetDefaultGateway(sdknet, addrstr); +prlsdkCheckRetGoto(pret, cleanup); + +alreadySetIPv4Gateway = true; +break; + +case AF_INET6: +if (alreadySetIPv6Gateway) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Support only one IPv6 default gateway)); +goto cleanup; +} + +if (!(addrstr =
[libvirt] [glib] Don't overwrite filesystem type when writing format
When setting filesystem driver format first and type, only the type remained and vice-versa. --- libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 8 ++-- tests/test-gconfig.c | 2 +- tests/xml/gconfig-domain-device-filesys.xml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c index 9b73af5..4e33d5f 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c @@ -125,7 +125,9 @@ 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_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); +node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), driver); +if (!node) +node = gvir_config_object_add_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( @@ -143,7 +145,9 @@ void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *files GVirConfigObject *node; g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys)); -node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); +node = gvir_config_object_get_child(GVIR_CONFIG_OBJECT(filesys), driver); +if (!node) +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), driver); g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node)); gvir_config_object_set_attribute_with_type( diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index bd2daa6..0eec53e 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -368,7 +368,7 @@ static void test_domain_device_filesystem(void) 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_driver_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD); 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); diff --git a/tests/xml/gconfig-domain-device-filesys.xml b/tests/xml/gconfig-domain-device-filesys.xml index 30152d2..a831c02 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 format=qcow2/ + driver type=nbd 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
Re: [libvirt] [PATCH v2 08/10] qemu: Fix integer/boolean logic in qemuSetUnprivSGIO
On Mon, Jul 06, 2015 at 13:08:36 -0400, John Ferlan wrote: Setting of 'val' is a boolean expression, so handle it that way and adjust the check/return logic to be clearer Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 5ebf2cc..589a6cf 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1447,7 +1447,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) virDomainHostdevDefPtr hostdev = NULL; char *sysfs_path = NULL; const char *path = NULL; -int val = -1; +bool val = false; No need to initialize val here, since it's written first. int ret = -1; /* sgio is only valid for block disk; cdrom @@ -1488,8 +1488,12 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) * whitelist is enabled. But if requesting unfiltered access, always call * virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio. */ -if ((virFileExists(sysfs_path) || val == 1) -virSetDeviceUnprivSGIO(path, NULL, val) 0) +if (!val || !virFileExists(sysfs_path)) { +ret = 0; +goto cleanup; +} + +if (virSetDeviceUnprivSGIO(path, NULL, 1) 0) goto cleanup; ret = 0; 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 07/10] qemu: Refactor qemuSetUnprivSGIO return values
On Mon, Jul 06, 2015 at 13:08:35 -0400, John Ferlan wrote: Set to ret = -1 and prove otherwise, like usual Signed-off-by: John Ferlan jfer...@redhat.com --- src/qemu/qemu_conf.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 80b8926..5ebf2cc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1448,7 +1448,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) char *sysfs_path = NULL; const char *path = NULL; int val = -1; -int ret = 0; +int ret = -1; /* sgio is only valid for block disk; cdrom * and floopy disk can have empty source. @@ -1467,24 +1467,19 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) if (!qemuIsSharedHostdev(hostdev)) return 0; -if (hostdev-source.subsys.u.scsi.sgio) { +if (hostdev-source.subsys.u.scsi.sgio) virReportError(VIR_ERR_INTERNAL_ERROR, %s, _('sgio' is not supported for SCSI generic device yet )); -ret = -1; goto cleanup; -} Wrong removal of the braces. return 0; } else { return 0; } signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [java] [PATCH 0/6] Fix JNA wrapping, fix memory leaks and wrap security model / label function
Hi. At Wed, 28 Jan 2015 21:45:41 +0100, Claudio Bley wrote: Hi. First and foremost, this series fixes a few mistakes in the wrapping code found by inspecting the org.libvirt.jna.Libvirt interface and the corresponding C types of the XML API file. The last two patches add two missing functions introduced in libvirt 0.6.1. At the end of the day, this means libvirt-java has gained full coverage of the libvirt functions up to and including version 0.8.5. Yay! Claudio Bley (6): JNA: fix wrong return type void vs. int JNA: add CString class and fix memory leaks JNA: simplify freeing memory for C strings Use the CString class for Arrays of CStrings too Implement Domain.getSecurityLabel and add SecurityLabel class Implement Connect.getSecurityModel and add SecurityModel class It has been a while since I posted these patches. Because nobody objected until now, I'm just going to push them. -- Claudio -- -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 2/2] Dsitribute the whole tests/xml folder
--- tests/Makefile.am | 14 +- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 63865e8..7189d6f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,18 +17,6 @@ LDADD = \ test_programs = test-gconfig test-events EXTRA_DIST += \ - xml/gconfig-domain.xml \ - xml/gconfig-domain-clock.xml \ - xml/gconfig-domain-cpu.xml \ - xml/gconfig-domain-device-channel.xml \ - xml/gconfig-domain-device-console.xml \ - xml/gconfig-domain-device-disk.xml \ - xml/gconfig-domain-device-graphics.xml \ - xml/gconfig-domain-device-input.xml \ - xml/gconfig-domain-device-network.xml \ - xml/gconfig-domain-device-sound.xml \ - xml/gconfig-domain-device-usbredir.xml \ - xml/gconfig-domain-device-video.xml \ - xml/gconfig-domain-os.xml \ + xml \ $(NULL) endif -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 0/2] misc gconfig fixes
Hi all, Here is a version fixing two bugs I introduced. Diff to v1: * takes into account teuf's comments. Cédric Bosdonnat (2): Don't overwrite filesystem type when writing format Dsitribute the whole tests/xml folder libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 4 ++-- tests/Makefile.am| 14 +- tests/test-gconfig.c | 2 +- tests/xml/gconfig-domain-device-filesys.xml | 2 +- 4 files changed, 5 insertions(+), 17 deletions(-) -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [glib v2 1/2] Don't overwrite filesystem type when writing format
When setting filesystem driver format first and type, only the type remained and vice-versa. --- libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 4 ++-- tests/test-gconfig.c | 2 +- tests/xml/gconfig-domain-device-filesys.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c index 9b73af5..860480c 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_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); +node = gvir_config_object_add_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( @@ -143,7 +143,7 @@ void gvir_config_domain_filesys_set_driver_format(GVirConfigDomainFilesys *files GVirConfigObject *node; g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys)); -node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys), driver); +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), driver); g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node)); gvir_config_object_set_attribute_with_type( diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c index bd2daa6..0eec53e 100644 --- a/tests/test-gconfig.c +++ b/tests/test-gconfig.c @@ -368,7 +368,7 @@ static void test_domain_device_filesystem(void) 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_driver_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD); 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); diff --git a/tests/xml/gconfig-domain-device-filesys.xml b/tests/xml/gconfig-domain-device-filesys.xml index 30152d2..a831c02 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 format=qcow2/ + driver type=nbd 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
Re: [libvirt] [libvirt-glib PATCHv5 7/7] gobject: Add wrapper for virNetworkGetDHCPLeases
On Tue, Jul 07, 2015 at 03:17:37PM +0100, Zeeshan Ali (Khattak) wrote: --- libvirt-gobject/libvirt-gobject-network.c | 55 +++ libvirt-gobject/libvirt-gobject-network.h | 4 +++ libvirt-gobject/libvirt-gobject.sym | 2 ++ 3 files changed, 61 insertions(+) diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c index b1b38a0..2a7bed6 100644 --- a/libvirt-gobject/libvirt-gobject-network.c +++ b/libvirt-gobject/libvirt-gobject-network.c @@ -29,6 +29,7 @@ #include libvirt-glib/libvirt-glib.h #include libvirt-gobject/libvirt-gobject.h #include libvirt-gobject-compat.h +#include libvirt-gobject/libvirt-gobject-network-dhcp-lease-private.h #define GVIR_NETWORK_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_NETWORK, GVirNetworkPrivate)) @@ -224,3 +225,57 @@ GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network, free(xml); return conf; } + +/** + * gvir_network_get_dhcp_leases: + * @network: the network + * @mac: (allow-none): The optional ASCII formatted MAC address of an interface + * @flags: placeholder for flags, must be 0 + * + * @err: Place-holder for possible errors + * + * This function fetches leases info of guests in the specified network. If the + * optional parameter @mac is specified, the returned list will contain only + * lease info about a specific guest interface with @mac. There can be multiple + * leases for a single @mac because this API supports DHCPv6 too. + * + * Returns: (element-type LibvirtGObject.NetworkDHCPLease) (transfer full): the + * list of network leases. Each object in the returned list should be unreffed + * with g_object_unref() and the list itself using g_list_free, when no longer + * needed. + */ +GList *gvir_network_get_dhcp_leases(GVirNetwork *network, +const char* mac, +guint flags, +GError **err) +{ +virNetworkDHCPLeasePtr *leases; +GList *ret = NULL; +int num_leases, i; + +g_return_val_if_fail(GVIR_IS_NETWORK(network), NULL); +g_return_val_if_fail(err == NULL || *err == NULL, NULL); +g_return_val_if_fail(flags != 0, NULL); + +num_leases = virNetworkGetDHCPLeases(network-priv-handle, mac, leases, flags); +if (num_leases 0) { +gvir_set_error_literal(err, GVIR_NETWORK_ERROR, + 0, + Unable to get network DHCP leases); +return NULL; +} + +if (num_leases == 0) +return NULL; + +for (i = 0; i num_leases; i++) { +GVirNetworkDHCPLease *lease; + +lease = gvir_network_dhcp_lease_new(leases[i]); +ret = g_list_prepend(ret, lease); +} +ret = g_list_reverse(ret); +free(leases); + +return ret; Could be return g_list_reverse(ret); and drop the ret = g_list_reverse(ret); above, but both are good for me. Christophe pgpV8YhCQYT_n.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib PATCHv5 1/7] gobject: Simplify gvir_connection_list*() implementations
Hey, A 'changes since v4' section would have been nice ACK series. Christophe On Tue, Jul 07, 2015 at 03:17:31PM +0100, Zeeshan Ali (Khattak) wrote: Make use of virConnectListAll* functions to avoid making 4 calls and hence avoid race conditions and complicated code. --- libvirt-gobject/libvirt-gobject-connection.c | 203 --- 1 file changed, 28 insertions(+), 175 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index cf073a5..e088427 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -680,48 +680,6 @@ void gvir_connection_close(GVirConnection *conn) g_signal_emit(conn, signals[VIR_CONNECTION_CLOSED], 0); } -typedef gint (* CountFunction) (virConnectPtr vconn); -typedef gint (* ListFunction) (virConnectPtr vconn, gchar **lst, gint max); - -static gchar ** fetch_list(virConnectPtr vconn, - const char *name, - CountFunction count_func, - ListFunction list_func, - GCancellable *cancellable, - gint *length, - GError **err) -{ -gchar **lst = NULL; -gint n = 0; - -if ((n = count_func(vconn)) 0) { -gvir_set_error(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to count %s), name); -goto error; -} - -if (n) { -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto error; - -lst = g_new0(gchar *, n); -if ((n = list_func(vconn, lst, n)) 0) { -gvir_set_error(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to list %s %d), name, n); -goto error; -} -} - -*length = n; -return lst; - -error: -g_free(lst); -return NULL; -} - /** * gvir_connection_fetch_domains: * @conn: a #GVirConnection @@ -733,14 +691,11 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, { GVirConnectionPrivate *priv; GHashTable *doms; -gchar **inactive = NULL; -gint ninactive = 0; -gint *active = NULL; -gint nactive = 0; +virDomainPtr *domains = NULL; +gint ndomains = 0; gboolean ret = FALSE; gint i; virConnectPtr vconn = NULL; -GError *lerr = NULL; g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); g_return_val_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable), @@ -761,81 +716,28 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, virConnectRef(vconn); g_mutex_unlock(priv-lock); -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto cleanup; - -if ((nactive = virConnectNumOfDomains(vconn)) 0) { -gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to count domains)); +ndomains = virConnectListAllDomains(vconn, domains, 0); +if (ndomains 0) { +gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + _(Failed to fetch list of domains)); goto cleanup; } -if (nactive) { -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto cleanup; - -active = g_new(gint, nactive); -if ((nactive = virConnectListDomains(vconn, active, nactive)) 0) { -gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, - 0, - _(Unable to list domains)); -goto cleanup; -} -} if (g_cancellable_set_error_if_cancelled(cancellable, err)) goto cleanup; -inactive = fetch_list(vconn, - Domains, - virConnectNumOfDefinedDomains, - virConnectListDefinedDomains, - cancellable, - ninactive, - lerr); -if (lerr) { -g_propagate_error(err, lerr); -lerr = NULL; -goto cleanup; -} - doms = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); -for (i = 0 ; i nactive ; i++) { -if (g_cancellable_set_error_if_cancelled(cancellable, err)) -goto cleanup; - -virDomainPtr vdom = virDomainLookupByID(vconn, active[i]); +for (i = 0 ; i ndomains; i++) { GVirDomain *dom; -if (!vdom) -continue; dom = GVIR_DOMAIN(g_object_new(GVIR_TYPE_DOMAIN, -
[libvirt] [glib] Add filesys xml file to distribution
Tests can't succeed from the distribution tarball: the new gconfig-domain-device-filesys.xml file wasn't included. --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 63865e8..c8bb4c7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,6 +23,7 @@ EXTRA_DIST += \ xml/gconfig-domain-device-channel.xml \ xml/gconfig-domain-device-console.xml \ xml/gconfig-domain-device-disk.xml \ + xml/gconfig-domain-device-filesys.xml \ xml/gconfig-domain-device-graphics.xml \ xml/gconfig-domain-device-input.xml \ xml/gconfig-domain-device-network.xml \ -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list