Re: [libvirt] [PATCH 1/4 v3] pci: Add two new pci utils pciDeviceGetVirtualFunctionInfo and pciConfigAddressToSysfsFile
On 03/05/2012 08:12 PM, Roopa Prabhu wrote: From: Roopa Prabhu ropra...@cisco.com pciDeviceGetVirtualFunctionInfo returns pf netdevice name and virtual function index for a given vf. This is just a wrapper around existing functions to return vf's pf and vf_index with one api call pciConfigAddressToSysfsfile returns the sysfile pci device link from a 'struct pci_config_address' Signed-off-by: Roopa Prabhu ropra...@cisco.com --- src/util/pci.c | 55 +++ src/util/pci.h |7 +++ 2 files changed, 62 insertions(+), 0 deletions(-) diff --git a/src/util/pci.c b/src/util/pci.c index c660e8d..c8a5287 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -2081,6 +2081,20 @@ pciSysfsFile(char *pciDeviceName, char **pci_sysfs_device_link) return 0; } +int +pciConfigAddressToSysfsFile(struct pci_config_address *dev, +char **pci_sysfs_device_link) +{ +if (virAsprintf(pci_sysfs_device_link, +PCI_SYSFS devices/%04x:%02x:%02x.%x, dev-domain, +dev-bus, dev-slot, dev-function) 0) { +virReportOOMError(); +return -1; +} + +return 0; +} + /* * Returns the network device name of a pci device */ @@ -2123,6 +2137,38 @@ out: return ret; } + +int +pciDeviceGetVirtualFunctionInfo(const char *vf_sysfs_device_path, +char **pfname, int *vf_index) +{ +struct pci_config_address *pf_config_address = NULL; +char *pf_sysfs_device_path = NULL; +int ret = -1; + +if (pciGetPhysicalFunction(vf_sysfs_device_path, pf_config_address) 0) +return ret; + +if (pciConfigAddressToSysfsFile(pf_config_address, +pf_sysfs_device_path) 0) { + +VIR_FREE(pf_config_address); +return ret; +} + +if (pciGetVirtualFunctionIndex(pf_sysfs_device_path, vf_sysfs_device_path, +vf_index) 0) +goto cleanup; + +ret = pciDeviceNetName(pf_sysfs_device_path, pfname); + +cleanup: +VIR_FREE(pf_config_address); +VIR_FREE(pf_sysfs_device_path); + +return ret; +} + #else int pciGetPhysicalFunction(const char *vf_sysfs_path ATTRIBUTE_UNUSED, @@ -2170,4 +2216,13 @@ pciDeviceNetName(char *device_link_sysfs_path ATTRIBUTE_UNUSED, supported on non-linux platforms)); return -1; } + +int +pciDeviceGetVirtualFunctionInfo(const char *vf_sysfs_device_path ATTRIBUTE_UNUSED, +char **pfname, int *vf_index ATTRIBUTE_UNUSED) +{ +pciReportError(VIR_ERR_INTERNAL_ERROR, _(pciDeviceGetVirtualFunctionInfo + is not supported on non-linux platforms)); +return -1; +} #endif /* __linux__ */ diff --git a/src/util/pci.h b/src/util/pci.h index 25b5b66..b71bb12 100644 --- a/src/util/pci.h +++ b/src/util/pci.h @@ -111,6 +111,9 @@ int pciGetVirtualFunctionIndex(const char *pf_sysfs_device_link, const char *vf_sysfs_device_link, int *vf_index); +int pciConfigAddressToSysfsFile(struct pci_config_address *dev, +char **pci_sysfs_device_link); + int pciDeviceNetName(char *device_link_sysfs_path, char **netname); int pciSysfsFile(char *pciDeviceName, char **pci_sysfs_device_link) @@ -122,4 +125,8 @@ int pciGetDeviceAddrString(unsigned domain, unsigned function, char **pciConfigAddr) ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK; + +int pciDeviceGetVirtualFunctionInfo(const char *vf_sysfs_device_path, +char **pfname, int *vf_index); + #endif /* __VIR_PCI_H__ */ After already ACKing this, I realized that the new functions weren't added to libvirt_private.syms. I'm squashing the following in before I push: diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2639b48..5d37618 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -864,6 +864,7 @@ virNWFilterVarValueGetSimple; # pci.h +pciConfigAddressToSysfsFile; pciDettachDevice; pciDeviceFileIterate; pciDeviceGetManaged; @@ -872,6 +873,7 @@ pciDeviceGetRemoveSlot; pciDeviceGetReprobe; pciDeviceGetUnbindFromStub; pciDeviceGetUsedBy; +pciDeviceGetVirtualFunctionInfo; pciDeviceIsAssignable; pciDeviceIsVirtualFunction; pciDeviceListAdd; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/4 v3] virtnetdev: Add support functions for mac and portprofile associations on a hostdev
On 03/05/2012 08:12 PM, Roopa Prabhu wrote: From: Roopa Prabhu ropra...@cisco.com This patch adds the following: - functions to set and get vf configs - Functions to replace and store vf configs (Only mac address is handled today. But the functions can be easily extended for vlans and other vf configs) - function to dump link dev info (This is moved from virnetdevvportprofile.c) Looks like you addressed all my issues. (I need to add cleanup return paths of virnetdev to my todo list to address the bits of ugliness the code movement pointed out). Signed-off-by: Roopa Prabhu ropra...@cisco.com --- src/util/virnetdev.c | 535 ++ src/util/virnetdev.h | 19 ++ 2 files changed, 553 insertions(+), 1 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 4aa7639..9f93fda 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1127,8 +1127,47 @@ virNetDevGetPhysicalFunction(const char *ifname, char **pfname) return ret; } -#else /* !__linux__ */ +/** + * virNetDevGetVirtualFunctionInfo: + * @vfname: name of the virtual function interface + * @pfname: name of the physical function + * @vf: vf index + * + * Returns 0 on success, -errno on failure. + * + */ +int +virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname, +int *vf) +{ +char *pf_sysfs_path = NULL, *vf_sysfs_path = NULL; +int ret = -1; + +*pfname = NULL; + +if (virNetDevGetPhysicalFunction(vfname, pfname) 0) +return ret; + +if (virNetDevSysfsFile(pf_sysfs_path, *pfname, device) 0) +goto cleanup; + +if (virNetDevSysfsFile(vf_sysfs_path, vfname, device) 0) +goto cleanup; + +ret = pciGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf); + +cleanup: +if (ret 0) +VIR_FREE(*pfname); + +VIR_FREE(vf_sysfs_path); +VIR_FREE(pf_sysfs_path); + +return ret; +} I didn't notice before that this new function wasn't being defined in the case that HAVE_LIBNL isn't defined. I'm squashing in an empty function just like all the others. + +#else /* !__linux__ */ int virNetDevGetVirtualFunctions(const char *pfname ATTRIBUTE_UNUSED, char ***vfname ATTRIBUTE_UNUSED, @@ -1165,4 +1204,498 @@ virNetDevGetPhysicalFunction(const char *ifname ATTRIBUTE_UNUSED, _(Unable to get physical function status on this platform)); return -1; } + #endif /* !__linux__ */ +#if defined(__linux__) defined(HAVE_LIBNL) + +static struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = { +[IFLA_VF_MAC] = { .type = NLA_UNSPEC, +.maxlen = sizeof(struct ifla_vf_mac) }, +[IFLA_VF_VLAN] = { .type = NLA_UNSPEC, +.maxlen = sizeof(struct ifla_vf_vlan) }, +}; + +/** + * virNetDevLinkDump: + * + * @ifname: The name of the interface; only use if ifindex 0 + * @ifindex: The interface index; may be 0 if ifname is given + * @nltarget_kernel: whether to send the message to the kernel or another + * process + * @nlattr: pointer to a pointer of netlink attributes that will contain + * the results + * @recvbuf: Pointer to the buffer holding the returned netlink response + * message; free it, once not needed anymore + * @getPidFunc: Pointer to a function that will be invoked if the kernel + * is not the target of the netlink message but it is to be + * sent to another process. + * + * Get information about an interface given its name or index. + * + * Returns 0 on success, -1 on fatal error. + */ +int +virNetDevLinkDump(const char *ifname, int ifindex, + bool nltarget_kernel, struct nlattr **tb, + unsigned char **recvbuf, + uint32_t (*getPidFunc)(void)) +{ +int rc = 0; +struct nlmsghdr *resp; +struct nlmsgerr *err; +struct ifinfomsg ifinfo = { +.ifi_family = AF_UNSPEC, +.ifi_index = ifindex +}; +unsigned int recvbuflen; +uint32_t pid = 0; +struct nl_msg *nl_msg; + +*recvbuf = NULL; + +if (ifname ifindex = 0 virNetDevGetIndex(ifname, ifindex) 0) +return -1; + +ifinfo.ifi_index = ifindex; + +nl_msg = nlmsg_alloc_simple(RTM_GETLINK, NLM_F_REQUEST); +if (!nl_msg) { +virReportOOMError(); +return -1; +} + +if (nlmsg_append(nl_msg, ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO) 0) +goto buffer_too_small; + +if (ifname) { +if (nla_put(nl_msg, IFLA_IFNAME, strlen(ifname)+1, ifname) 0) +goto buffer_too_small; +} + +if (!nltarget_kernel) { +pid = getPidFunc(); +if (pid == 0) { +rc = -1; +goto cleanup; +} +} + +if
Re: [libvirt] [PATCH 3/4 v3] virnetdevvportprofile: Changes to support portprofiles for hostdevs
On 03/05/2012 08:12 PM, Roopa Prabhu wrote: From: Roopa Prabhu ropra...@cisco.com This patch includes the following changes - removes some netlink functions which are now available in virnetdev.c - Adds a vf argument to all port profile functions For 802.1Qbh devices, the port profile calls can use a vf argument if passed by the caller. If the vf argument is -1 it will try to derive the vf if the device passed is a virtual function. For 802.1Qbg devices, This patch introduces a null check for the device argument because during port profile assignment on a hostdev, this argument can be null. Stefan CC'ed for comments ACK. (I'm shortening the summary line so that it's 72 columns :-) I'll push this along with the others after I review 4/4. Signed-off-by: Roopa Prabhu ropra...@cisco.com --- src/qemu/qemu_migration.c|2 src/util/virnetdevmacvlan.c |8 + src/util/virnetdevvportprofile.c | 221 -- src/util/virnetdevvportprofile.h |8 + 4 files changed, 59 insertions(+), 180 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 5c4297c..77d40c0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2650,6 +2650,7 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def) { virDomainNetGetActualVirtPortProfile(net), net-mac, virDomainNetGetActualDirectDev(net), + -1, def-uuid, VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH, false) 0) goto err_exit; @@ -2667,6 +2668,7 @@ err_exit: virDomainNetGetActualVirtPortProfile(net), net-mac, virDomainNetGetActualDirectDev(net), + -1, VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH)); } } diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index f38a98c..647679f 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -452,6 +452,7 @@ struct virNetlinkCallbackData { virNetDevVPortProfilePtr virtPortProfile; unsigned char *macaddress; char *linkdev; +int vf; unsigned char *vmuuid; enum virNetDevVPortProfileOp vmOp; unsigned int linkState; @@ -719,6 +720,7 @@ virNetDevMacVLanVPortProfileCallback(unsigned char *msg, calld-virtPortProfile, calld-macaddress, calld-linkdev, +calld-vf, calld-vmuuid, calld-vmOp, true)); *handled = true; @@ -810,6 +812,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, const char *cr_ifname; virNetlinkCallbackDataPtr calld = NULL; int ret; +int vf = -1; macvtapMode = modeMap[mode]; @@ -871,6 +874,7 @@ create_name: virtPortProfile, macaddress, linkdev, + vf, vmuuid, vmOp, false) 0) { rc = -1; goto link_del_exit; @@ -948,6 +952,7 @@ disassociate_exit: virtPortProfile, macaddress, linkdev, + vf, vmOp)); link_del_exit: @@ -975,6 +980,8 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname, char *stateDir) { int ret = 0; +int vf = -1; + if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) { ignore_value(virNetDevRestoreMacAddress(linkdev, stateDir)); } @@ -984,6 +991,7 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname, virtPortProfile, macaddr, linkdev, + vf, VIR_NETDEV_VPORT_PROFILE_OP_DESTROY) 0)
Re: [libvirt] [PATCHv2 00/17] Support for interface type='hostdev'
On 02/28/2012 03:14 PM, Laine Stump wrote: This series of patches enhances the interface device to support a sort of intelligent hostdev, i.e. PCI passthrough where device-type specific initialization is done prior to assigning the device to the guest, in particular to allow setting the MAC address and do 802.1QbX setup for network devices. I've pushed the entire series, as listed below: + [PATCH 01/17] conf: add missing device types to [PATCH 02/17] conf: relocate virDomainDeviceDef and X [PATCH 03/17] conf: reorder static functions in domain_conf.c + [PATCH 04/17] qemu: rename virDomainDeviceInfoPtr variables to avoid + [PATCH 05/17] conf: add device pointer to args of [PATCH 06/17] conf: make hostdev info a separate object X [PATCH 07/17] conf: HostdevDef parse/format helper functions + [PATCH 09/17] conf: put subsys part of virDomainHostdevDef into its + [PATCH 10/17] conf: hostdev utility functions + [PATCH 11/17] qemu: re-order functions in qemu_hotplug.c + [PATCH 12/17] qemu: refactor hotplug detach of hostdevs + [PATCH 15/17] conf: change virDomainNetRemove from static to global + [PATCH 16/17] qemu: use virDomainNetRemove instead of inline code Patch 8 is just a couple lines: [PATCH 08/17] conf: give each hostdevdef a parent pointer [PATCH 13/17] conf: parse/format type='hostdev' network interfaces + [PATCH 14/17] qemu: support type='hostdev' network devices at domain start + [PATCH 17/17] qemu: support type=hostdev network device live hotplug -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4 v3] qemu_hostdev: Add support to install port profile and mac address on hostdevs
On 03/05/2012 08:12 PM, Roopa Prabhu wrote: From: Roopa Prabhu ropra...@cisco.com These changes are applied only if the hostdev has a parent net device. If the parent netdevice has virtual port information, the original virtualport associate functions are called (these set and restore both mac and port profile on an interface). Else, only mac address is set on the device using other methods depending on if its a sriov device or not. Changes also include hotplug pci devices Signed-off-by: Roopa Prabhu ropra...@cisco.com --- src/qemu/qemu_hostdev.c | 241 +-- src/qemu/qemu_hostdev.h |8 +- src/qemu/qemu_hotplug.c | 10 ++ 3 files changed, 246 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index b3cad8e..ebcdc52 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -29,6 +29,13 @@ #include memory.h #include pci.h #include hostusb.h +#include virnetdev.h + +VIR_ENUM_IMPL(virNetDevVPort, VIR_NETDEV_VPORT_PROFILE_LAST, + none, + 802.1Qbg, + 802.1Qbh, + openvswitch) static pciDeviceList * qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs) @@ -156,19 +163,192 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver, return 0; } +static int +qemuDomainHostdevPciSysfsPath(virDomainHostdevDefPtr hostdev, char **sysfs_path) +{ +struct pci_config_address config_address; + +config_address.domain = hostdev-source.subsys.u.pci.domain; +config_address.bus = hostdev-source.subsys.u.pci.bus; +config_address.slot = hostdev-source.subsys.u.pci.slot; +config_address.function = hostdev-source.subsys.u.pci.function; + +return pciConfigAddressToSysfsFile(config_address, sysfs_path); +} + +int +qemuDomainHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev) +{ +char *sysfs_path = NULL; +int ret = -1; + +if (qemuDomainHostdevPciSysfsPath(hostdev, sysfs_path) 0) +return ret; + +ret = pciDeviceIsVirtualFunction(sysfs_path); + +VIR_FREE(sysfs_path); + +return ret; +} + +static int +qemuDomainHostdevNetDevice(virDomainHostdevDefPtr hostdev, char **linkdev, + int *vf) +{ +int ret = -1; +char *sysfs_path = NULL; + +if (qemuDomainHostdevPciSysfsPath(hostdev, sysfs_path) 0) +return ret; + +if (pciDeviceIsVirtualFunction(sysfs_path) == 1) { +if (pciDeviceGetVirtualFunctionInfo(sysfs_path, linkdev, +vf) 0) +goto cleanup; +} else { +if (pciDeviceNetName(sysfs_path, linkdev) 0) +goto cleanup; +*vf = -1; +} + +ret = 0; + +cleanup: +VIR_FREE(sysfs_path); + +return ret; +} + +static int +qemuDomainHostdevNetConfigVirtPortProfile(const char *linkdev, int vf, + virNetDevVPortProfilePtr virtPort, + const unsigned char *macaddr, + const unsigned char *uuid, + int associate) +{ +int ret = -1; + +if (!virtPort) +return ret; + +switch(virtPort-virtPortType) { +case VIR_NETDEV_VPORT_PROFILE_NONE: +case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH: +case VIR_NETDEV_VPORT_PROFILE_8021QBG: +case VIR_NETDEV_VPORT_PROFILE_LAST: +qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(virtualport type %s is +currently not supported on interfaces of type +hostdev), +virNetDevVPortTypeToString(virtPort-virtPortType)); +break; + +case VIR_NETDEV_VPORT_PROFILE_8021QBH: +if (associate) +ret = virNetDevVPortProfileAssociate(NULL, virtPort, macaddr, + linkdev, vf, uuid, + VIR_NETDEV_VPORT_PROFILE_OP_CREATE, false); +else +ret = virNetDevVPortProfileDisassociate(NULL, virtPort, +macaddr, linkdev, vf, + VIR_NETDEV_VPORT_PROFILE_OP_DESTROY); +break; +} + +return ret; +} + +int +qemuDomainHostdevNetConfigReplace(virDomainHostdevDefPtr hostdev, + const unsigned char *uuid, + char *stateDir) +{ +char *linkdev = NULL; +virNetDevVPortProfilePtr virtPort; +int ret = -1; +int vf = -1; +int vlanid = -1; +int port_profile_associate = 1; +int isvf; + +isvf = qemuDomainHostdevIsVirtualFunction(hostdev); +if (isvf = 0) { +
Re: [libvirt] [PATCH 1/3 V7] add nodeGetCPUmap() for getting available CPU IDs in a cpumap.
On Fri, Mar 02, 2012 at 10:54:22AM +0800, Lai Jiangshan wrote: +/* + * Linux maintains cpu bit map. For example, if cpuid=5's flag is not set + * and max cpu is 7. The map file shows 0-4,6-7. This function parses + * it and returns cpumap. + */ +static const char * +linuxParseCPUmap(int *max_cpuid, const char *path) +{ +char *map = NULL; +char *str = NULL; +int max_id, i; + +if (virFileReadAll(path, 5 * VIR_DOMAIN_CPUMASK_LEN, str) 0) { +virReportOOMError(); +goto error; +} + +if (VIR_ALLOC_N(map, VIR_DOMAIN_CPUMASK_LEN) 0) { +virReportOOMError(); +goto error; +} +if (virDomainCpuSetParse(str, 0, map, + VIR_DOMAIN_CPUMASK_LEN) 0) { +goto error; +} + +for (i = 0; i VIR_DOMAIN_CPUMASK_LEN; i++) { +if (map[i]) { +max_id = i; +} +} +*max_cpuid = max_id; Please compile with './configure --enable-compile-warnings=error'. The compiler spots that max_id could be used uninitialized here. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4 v3] qemu_hostdev: Add support to install port profile and mac address on hostdevs
On 03/05/2012 08:12 PM, Roopa Prabhu wrote: From: Roopa Prabhu ropra...@cisco.com These changes are applied only if the hostdev has a parent net device. If the parent netdevice has virtual port information, the original virtualport associate functions are called (these set and restore both mac and port profile on an interface). Else, only mac address is set on the device using other methods depending on if its a sriov device or not. Changes also include hotplug pci devices Signed-off-by: Roopa Prabhu ropra...@cisco.com --- src/qemu/qemu_hostdev.c | 241 +-- src/qemu/qemu_hostdev.h |8 +- src/qemu/qemu_hotplug.c | 10 ++ 3 files changed, 246 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index b3cad8e..ebcdc52 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -29,6 +29,13 @@ #include memory.h #include pci.h #include hostusb.h +#include virnetdev.h + +VIR_ENUM_IMPL(virNetDevVPort, VIR_NETDEV_VPORT_PROFILE_LAST, + none, + 802.1Qbg, + 802.1Qbh, + openvswitch) Oops. I didn't notice this until I got to the final build test before pushing - VIR_ENUM_IMPL defines global functions, so you can't define it twice for the same type. Instead, just export the xxxToString and xxxFromString functions in libvirt_private.syms. I'm squashing that change into the commit. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] add screendump async to qemu
RHBZ: 800338 Adds a new capability to qemu, QEMU_CAPS_SCREENDUMP_ASYNC, available if the qmp command screendump-async exists. If that cap exists qemuDomainScreenshot uses it. The implementation consists of a hash from filename to struct holding the stream and temporary fd. The fd is closed and the stream is written to (in reverse order) by the completion callback, qemuProcessScreenshotComplete. Note: in qemuDomainScreenshot I don't check for an existing entry in the screenshots hash table because we the key is a temporary filename, produced by mkstemp, and it's only unlinked at qemuProcessScreenshotComplete. For testing you need to apply the following patches (they are still pending review on qemu-devel): http://patchwork.ozlabs.org/patch/144706/ http://patchwork.ozlabs.org/patch/144705/ http://patchwork.ozlabs.org/patch/144704/ Signed-off-by: Alon Levy al...@redhat.com --- src/qemu/qemu_capabilities.c |1 + src/qemu/qemu_capabilities.h |1 + src/qemu/qemu_domain.c |6 ++ src/qemu/qemu_domain.h | 12 src/qemu/qemu_driver.c | 42 +++--- src/qemu/qemu_monitor.c | 26 ++ src/qemu/qemu_monitor.h |8 src/qemu/qemu_monitor_json.c | 39 +++ src/qemu/qemu_monitor_json.h |3 +++ src/qemu/qemu_process.c | 29 + 10 files changed, 160 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 64a4546..57771ff 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -154,6 +154,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, drive-iotune, /* 85 */ system_wakeup, scsi-disk.channel, + screendump-async, ); struct qemu_feature_flags { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index db584ce..24d620d 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -122,6 +122,7 @@ enum qemuCapsFlags { QEMU_CAPS_DRIVE_IOTUNE = 85, /* -drive bps= and friends */ QEMU_CAPS_WAKEUP = 86, /* system_wakeup monitor command */ QEMU_CAPS_SCSI_DISK_CHANNEL = 87, /* Is scsi-disk.channel available? */ +QEMU_CAPS_SCREENDUMP_ASYNC = 88, /* screendump-async qmp command */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2fed91e..acf56c4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -181,6 +181,10 @@ qemuDomainObjFreeJob(qemuDomainObjPrivatePtr priv) ignore_value(virCondDestroy(priv-job.asyncCond)); } +static void +freeScreenshot(void *payload, const void *name ATTRIBUTE_UNUSED) { +VIR_FREE(payload); +} static void *qemuDomainObjPrivateAlloc(void) { @@ -196,6 +200,8 @@ static void *qemuDomainObjPrivateAlloc(void) goto error; priv-migMaxBandwidth = QEMU_DOMAIN_DEFAULT_MIG_BANDWIDTH_MAX; +priv-screenshots = virHashCreate(QEMU_DOMAIN_SCREENSHOTS_CONCURRENT_MAX, + freeScreenshot); return priv; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 1333d8c..15721ec 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -40,6 +40,8 @@ # define QEMU_DOMAIN_DEFAULT_MIG_BANDWIDTH_MAX 32 +# define QEMU_DOMAIN_SCREENSHOTS_CONCURRENT_MAX 16 + # define JOB_MASK(job) (1 (job - 1)) # define DEFAULT_JOB_MASK \ (JOB_MASK(QEMU_JOB_QUERY) | \ @@ -91,6 +93,14 @@ struct qemuDomainJobObj { virDomainJobInfo info; /* Async job progress data */ }; +struct _qemuScreenshotAsync { +virStreamPtr stream;/* stream to write results to */ +const char *filename; /* temporary file to read results from */ +int fd; /* handle to open temporary file */ +}; +typedef struct _qemuScreenshotAsync qemuScreenshotAsync; +typedef qemuScreenshotAsync *qemuScreenshotAsyncPtr; + typedef struct _qemuDomainPCIAddressSet qemuDomainPCIAddressSet; typedef qemuDomainPCIAddressSet *qemuDomainPCIAddressSetPtr; @@ -130,6 +140,8 @@ struct _qemuDomainObjPrivate { char *origname; virConsolesPtr cons; + +virHashTablePtr screenshots; }; struct qemuDomainWatchdogEvent diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 733df0a..e397bc3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3135,6 +3135,7 @@ qemuDomainScreenshot(virDomainPtr dom, int tmp_fd = -1; char *ret = NULL; bool unlink_tmp = false; +qemuScreenshotAsync *screenshot; virCheckFlags(0, NULL); @@ -3184,9 +3185,34 @@ qemuDomainScreenshot(virDomainPtr dom, virSecurityManagerSetSavedStateLabel(qemu_driver-securityManager, vm-def, tmp);
Re: [libvirt] [PATCH 0/4 v3] Support mac and port profile for interface type='hostdev'
On 03/05/2012 08:12 PM, Roopa Prabhu wrote: This series implements the below : 01/4 pci: Add two new pci util pciDeviceGetVirtualFunctionInfo and pciConfigAddressToSysfsFile 02/4 virtnetdev: Add support functions for mac and portprofile associations on a hostdev 03/4 virnetdevvportprofile: Changes to support portprofiles for hostdevs 04/4 qemu_hostdev: Add support to install port profile and mac address on hostdev Okay, I've pushed this series, with the few small nits I pointed out squashed in. Thanks for the contribution! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 01/15] docs: use correct terminology for 1024 bytes
On 03/06/2012 01:34 AM, Eric Blake wrote: Yes, I like kilobytes better than kibibytes (when I say kilobytes, I generally mean 1024). But since the term is ambiguous, it can't hurt to say what we mean, by using both the correct name and calling out the numeric equivalent. * src/libvirt.c (virDomainGetMaxMemory, virDomainSetMaxMemory) (virDomainSetMemory, virDomainSetMemoryFlags) (virNodeGetFreeMemory): Tweak wording. * docs/formatdomain.html.in: Likewise. * docs/formatstorage.html.in: Likewise. --- v2: separate doc changes out early docs/formatdomain.html.in | 15 --- docs/formatstorage.html.in |8 ++-- src/libvirt.c | 10 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 0dcf6df..93d8ab2 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -236,8 +236,12 @@ br/ By default this is specified in bytes, but an optional codeunit/code can be specified to adjust the passed value. -Values can be: 'K' (kilobytes), 'M' (megabytes), 'G' (gigabytes), -'T' (terabytes), 'P' (petabytes), or 'E' (exabytes). +Values can be: 'K' (kibibytes, 2sup10/sup or 1024), 'M' I'd probably write this as (kibibytes, 2sup10/sup or 1024 bytes) to be a little more specific, but it should be clear enough without it. +(mebibytes, 2sup20/sup or 1,048,576), 'G' (gibibytes, +2sup30/sup or 1,073,741,824), 'T' (tebibytes, +2sup40/sup or 1,099,511,627,776), 'P' (pebibytes, +2sup50/sup or 1,125,899,906,842,624), or 'E' (exbibytes, +2sup60/sup or 1,152,921,504,606,846,976). span class=sinceSince 0.4.1/span/dd dtcodecapacity/code/dt ddProviding the logical capacity for the volume. This value is ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3 V7] add nodeGetCPUmap() for getting available CPU IDs in a cpumap.
This all appears to work. I built my own libvirt with the three remaining patches and was able to read pCPU information for a running domain. I have pushed the required bits upstream in ocaml-libvirt and virt-top: http://git.annexia.org/?p=ocaml-libvirt.git;a=summary http://git.annexia.org/?p=virt-top.git;a=summary (ocaml-libvirt = 0.6.1.1 and virt-top = 1.0.7) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 02/15] api: add overflow error
On 03/06/2012 01:34 AM, Eric Blake wrote: Overflow can be user-induced, so it deserves more than being called an internal error. Note that in general, 32-bit platforms have Definitely. Internal error is always somewhat scary to users. far more places to trigger this error (anywhere the public API used 'unsigned long' but the other side of the connection is a 64-bit server); but some are possible on 64-bit platforms (where the public API computes the product of two numbers). * include/libvirt/virterror.h (VIR_ERR_OVERFLOW): New error. * src/util/virterror.c (virErrorMsg): Translate it. * src/libvirt.c (virDomainSetVcpusFlags, virDomainGetVcpuPinInfo) (virDomainGetVcpus, virDomainGetCPUStats): Use it. * daemon/remote.c (HYPER_TO_TYPE): Likewise. * src/qemu/qemu_driver.c (qemuDomainBlockResize): Likewise. --- ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/4 v3] Support mac and port profile for interface type='hostdev'
On 3/6/12 3:05 AM, Laine Stump la...@laine.org wrote: On 03/05/2012 08:12 PM, Roopa Prabhu wrote: This series implements the below : 01/4 pci: Add two new pci util pciDeviceGetVirtualFunctionInfo and pciConfigAddressToSysfsFile 02/4 virtnetdev: Add support functions for mac and portprofile associations on a hostdev 03/4 virnetdevvportprofile: Changes to support portprofiles for hostdevs 04/4 qemu_hostdev: Add support to install port profile and mac address on hostdev Okay, I've pushed this series, with the few small nits I pointed out squashed in. Thanks for the contribution! Thanks Laine. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 03/15] util: new function for scaling numbers
On 03/06/2012 01:34 AM, Eric Blake wrote: Scaling an integer based on a suffix is something we plan on reusing in several contexts: XML parsing, virsh CLI parsing, and possibly elsewhere. Make it easy to reuse, as well as adding in support for powers of 1000. * src/util/util.h (virScaleInteger): New function. * src/util/util.c (virScaleInteger): Implement it. * src/libvirt_private.syms (util.h): Export it. --- v2: new, but borrows ideas from memory v1 3/3 src/libvirt_private.syms |1 + src/util/util.c | 66 ++ src/util/util.h |4 +++ 3 files changed, 71 insertions(+), 0 deletions(-) diff --git a/src/util/util.c b/src/util/util.c index 7c58c7b..1b71680 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1632,6 +1632,72 @@ virHexToBin(unsigned char c) } } +/* Scale an integer VALUE by an optional SUFFIX in-place, defaulting + * to SCALE if no suffix is present. Ensure that the result does not + * exceed LIMIT. Return 0 on success, -1 with error message raised on + * failure. */ I'd write a little bit more on how the base selection works depending on the argument. Something like: For power-of-two scaling use the binary prefixes (i.e. KiB, MiB), for power of ten scaling use the SI prefixes (i.e. KB, Mb, ...). +int +virScaleInteger(unsigned long long *value, const char *suffix, +unsigned long long scale, unsigned long long limit) Looks good. ACK Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 04/15] xml: share 'unit' in RNG
On 03/06/2012 01:34 AM, Eric Blake wrote: The code supported unit='E' for exabyte, but the RNG did not; conversely, the RNG supported z and y but the code did not (I'm jealous if you have that much storage, particularly since it won't fit in 64-bit off_t). Also, the code supported allocation unit='...', but not the RNG. In an effort to make 'unit' more worthwhile in future patches, it's easier to share it between files. In making this factorization, note that absFilePath is more permissive than 'path', so storage pools and storage volumes will now validate with a wider set of file names than before. I don't think this should be a problem in practice. * docs/schemas/storagepool.rng: Include basic types, rather than repeating things here. * docs/schemas/storagevol.rng: Likewise. * docs/schemas/basictypes.rng: Add 'unsignedLong', 'unit', and fix to match storage code. --- There are more places that can be simplified including the basictypes.rng file. I'll post a separate patch for them. ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Patch]: spice agent-mouse support [v3]
On 2012年03月05日 16:17, Zhou Peng wrote: Signed-off-by: Zhou Pengzhoup...@nfs.iscas.ac.cn spice agent-mouse support Usage: graphics type='spice' mouse mode='client'|'server'/ graphics/ diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6fcca94..0adf859 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2809,6 +2809,14 @@ qemu-kvm -net nic,model=? /dev/null tocodeno/code,span class=sincesince 0.9.3/span. /p +p + It can be specified whether client or server mouse mode + to use for spice. The default is client which enables + passing mouse events via Spice agent. Not true from the codes, (no default value is set for mode). And think above lines can be omitted. It's duplicate with below somehow. Below is enough. + The mouse mode is set by thecodemousecode/ element, + setting it'scodemodecode/ attribute to one of +codeserver/code orcodeclient/code. Better to document since which release the element is introduced. e.g. span class=since0.9.11/span +/p /dd dtcoderdp/code/dt dd diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 3908733..bb0df03 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1776,6 +1776,17 @@ empty/ /element /optional +optional +element name=mouse +attribute name=mode +choice +valueserver/value +valueclient/value +/choice +/attribute +empty/ +/element +/optional /interleave /group group diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9654f1..b99e770 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -460,6 +460,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression, on, off); +VIR_ENUM_IMPL(virDomainGraphicsSpiceMouseMode, + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST, + default, + server, + client); + VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode, VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST, default, @@ -5710,6 +5716,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, VIR_FREE(copypaste); def-data.spice.copypaste = copypasteVal; +} else if (xmlStrEqual(cur-name, BAD_CAST mouse)) { +const char *mode = virXMLPropString(cur, mode); +int modeVal; + +if (!mode) { +virDomainReportError(VIR_ERR_XML_ERROR, %s, + _(spice mouse missing mode)); +goto error; +} + +if ((modeVal = + virDomainGraphicsSpiceMouseModeTypeFromString(mode))= 0) { +virDomainReportError(VIR_ERR_INTERNAL_ERROR, s/VIR_ERR_INTERNAL_ERROR/VIR_ERR_XML_ERROR/ + _(unknown mouse mode value '%s'), mode); +VIR_FREE(mode); +goto error; +} +VIR_FREE(mode); + +def-data.spice.mousemode = modeVal; } } cur = cur-next; @@ -11401,7 +11427,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, } if (!children (def-data.spice.image || def-data.spice.jpeg || def-data.spice.zlib || def-data.spice.playback || - def-data.spice.streaming || def-data.spice.copypaste)) { + def-data.spice.streaming || def-data.spice.copypaste || + def-data.spice.mousemode)) { virBufferAddLit(buf, \n); children = 1; } @@ -11420,6 +11447,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def-data.spice.streaming) virBufferAsprintf(buf, streaming mode='%s'/\n, virDomainGraphicsSpiceStreamingModeTypeToString(def-data.spice.streaming)); +if (def-data.spice.mousemode) +virBufferAsprintf(buf, mouse mode='%s'/\n, + virDomainGraphicsSpiceMouseModeTypeToString(def-data.spice.mousemode)); if (def-data.spice.copypaste) virBufferAsprintf(buf, clipboard copypaste='%s'/\n, virDomainGraphicsSpiceClipboardCopypasteTypeToString(def-data.spice.copypaste)); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 596be4d..a9c118a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1003,6 +1003,14 @@ enum virDomainGraphicsSpicePlaybackCompression { VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST }; +enum virDomainGraphicsSpiceMouseMode { +VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT = 0, +VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER, +
[libvirt] [PATCH] xml: Clean up schemas to use shared data types instead of local
The schema files contained duplicate data types that can be shared from the basictypes.rng file. --- docs/schemas/capability.rng | 43 + docs/schemas/interface.rng | 16 docs/schemas/nodedev.rng| 54 +++--- docs/schemas/nwfilter.rng | 28 +- 4 files changed, 32 insertions(+), 109 deletions(-) diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index 3af95e9..06ff685 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -1,6 +1,7 @@ !-- A Relax NG schema for the libvirt capabilities XML format -- grammar xmlns=http://relaxng.org/ns/structure/1.0; datatypeLibrary=http://www.w3.org/2001/XMLSchema-datatypes; + include href='basictypes.rng'/ start ref name='capabilities'/ /start @@ -157,7 +158,7 @@ element name='topology' element name='cells' attribute name='num' - ref name='uint'/ + ref name='unsignedInt'/ /attribute oneOrMore ref name='cell'/ @@ -169,13 +170,13 @@ define name='cell' element name='cell' attribute name='id' -ref name='uint'/ +ref name='unsignedInt'/ /attribute optional element name='cpus' attribute name='num' -ref name='uint'/ +ref name='unsignedInt'/ /attribute oneOrMore ref name='cpu'/ @@ -188,7 +189,7 @@ define name='cpu' element name='cpu' attribute name='id' -ref name='uint'/ +ref name='unsignedInt'/ /attribute /element /define @@ -238,13 +239,13 @@ define name='emulator' element name='emulator' - ref name='path'/ + ref name='absFilePath'/ /element /define define name='loader' element name='loader' - ref name='path'/ + ref name='absFilePath'/ /element /define @@ -367,39 +368,9 @@ /choice /define - - define name='positiveInteger' -data type='positiveInteger' - param name=pattern[0-9]+/param -/data - /define - - define name='uint' -data type='unsignedInt' - param name=pattern[0-9]+/param -/data - /define - - define name='path' -data type='string' - param name=pattern/[a-zA-Z0-9_\+\-/%]+/param -/data - /define - define name='featureName' data type='string' param name='pattern'[a-zA-Z0-9\-_]+/param /data /define - - define name=UUID -choice - data type=string -param name=pattern[a-fA-F0-9]{32}/param - /data - data type=string -param name=pattern[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}/param - /data -/choice - /define /grammar diff --git a/docs/schemas/interface.rng b/docs/schemas/interface.rng index 53fa18a..3984b63 100644 --- a/docs/schemas/interface.rng +++ b/docs/schemas/interface.rng @@ -183,12 +183,12 @@ choice element name=miimon !-- miimon frequency in ms -- -attribute name=freqref name=uint//attribute +attribute name=freqref name=unsignedInt//attribute optional - attribute name=downdelayref name=uint//attribute + attribute name=downdelayref name=unsignedInt//attribute /optional optional - attribute name=updelayref name=uint//attribute + attribute name=updelayref name=unsignedInt//attribute /optional optional !-- use_carrier -- @@ -203,7 +203,7 @@ /optional /element element name=arpmon -attribute name=intervalref name=uint//attribute +attribute name=intervalref name=unsignedInt//attribute attribute name=targetref name=ipv4Addr//attribute optional attribute name=validate @@ -252,7 +252,7 @@ define name=mtu optional element name=mtu -attribute name=sizeref name=uint//attribute +attribute name=sizeref name=unsignedInt//attribute /element /optional /define @@ -407,12 +407,6 @@ !-- Type library -- - define name='uint' -data type='unsignedInt' - param name=pattern[0-9]+/param -/data - /define - define name=timeval data type=double param name=minInclusive0/param diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 1b9a2d1..a73c2e5 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -1,6 +1,7 @@ !-- A Relax NG schema for the libvirt node device XML format -- grammar xmlns=http://relaxng.org/ns/structure/1.0; datatypeLibrary=http://www.w3.org/2001/XMLSchema-datatypes; + include href='basictypes.rng'/ start ref name='device'/ /start @@ -56,7 +57,7 @@ /optional element name='uuid' -ref name='uuid'/ +ref name='UUID'/ /element /element
Re: [libvirt] [PATCHv2 01/15] docs: use correct terminology for 1024 bytes
On Mon, Mar 05, 2012 at 05:34:16PM -0700, Eric Blake wrote: @@ -3619,7 +3619,7 @@ error: /** * virDomainSetMaxMemory: * @domain: a domain object or NULL - * @memory: the memory size in kilobytes + * @memory: the memory size in kibibytes (blocks of 1024) of 1024 bytes? I don't know how this looks to a native speaker, but this looks truncated to my French eyes if bytes is not there, same for the 2 other occurrences below. Christophe * * Dynamically change the maximum amount of physical memory allocated to a * domain. If domain is NULL, then this change the amount of memory reserved @@ -3674,7 +3674,7 @@ error: /** * virDomainSetMemory: * @domain: a domain object or NULL - * @memory: the memory size in kilobytes + * @memory: the memory size in kibibytes (blocks of 1024) * * Dynamically change the target amount of physical memory allocated to a * domain. If domain is NULL, then this change the amount of memory reserved @@ -3729,7 +3729,7 @@ error: /** * virDomainSetMemoryFlags: * @domain: a domain object or NULL - * @memory: the memory size in kilobytes + * @memory: the memory size in kibibytes (blocks of 1024) * @flags: bitwise-OR of virDomainMemoryModFlags * * Dynamically change the target amount of physical memory allocated to a @@ -6684,7 +6684,7 @@ error: * @conn: pointer to the hypervisor connection * * provides the free memory available on the Node - * Note: most libvirt APIs provide memory sizes in kilobytes, but in this + * Note: most libvirt APIs provide memory sizes in kibibytes, but in this * function the returned value is in bytes. Divide by 1024 as necessary. * * Returns the available free memory in bytes or 0 in case of error -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list pgpnVSMLQYRVK.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 01/15] docs: use correct terminology for 1024 bytes
On 03/06/2012 03:34 PM, Christophe Fergeau wrote: On Mon, Mar 05, 2012 at 05:34:16PM -0700, Eric Blake wrote: @@ -3619,7 +3619,7 @@ error: /** * virDomainSetMaxMemory: * @domain: a domain object or NULL - * @memory: the memory size in kilobytes + * @memory: the memory size in kibibytes (blocks of 1024) of 1024 bytes? I don't know how this looks to a native speaker, but this looks truncated to my French eyes if bytes is not there, same for the 2 other occurrences below. Christophe Oh yeah, my geeky brain inferred the bytes part automaticaly when it saw the number 1024. Adding the bytes makes it more clear for not-so-geeky people :). Eric, could you please add bytes to the appropriate places to make it more clear. Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] xml: Clean up schemas to use shared data types instead of local
On 2012年03月06日 22:15, Peter Krempa wrote: The schema files contained duplicate data types that can be shared from the basictypes.rng file. --- docs/schemas/capability.rng | 43 + docs/schemas/interface.rng | 16 docs/schemas/nodedev.rng| 54 +++--- docs/schemas/nwfilter.rng | 28 +- 4 files changed, 32 insertions(+), 109 deletions(-) diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng index 3af95e9..06ff685 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -1,6 +1,7 @@ !-- A Relax NG schema for the libvirt capabilities XML format -- grammar xmlns=http://relaxng.org/ns/structure/1.0; datatypeLibrary=http://www.w3.org/2001/XMLSchema-datatypes; +include href='basictypes.rng'/ start ref name='capabilities'/ /start @@ -157,7 +158,7 @@ element name='topology' element name='cells' attribute name='num' -ref name='uint'/ +ref name='unsignedInt'/ /attribute oneOrMore ref name='cell'/ @@ -169,13 +170,13 @@ define name='cell' element name='cell' attribute name='id' -ref name='uint'/ +ref name='unsignedInt'/ /attribute optional element name='cpus' attribute name='num' -ref name='uint'/ +ref name='unsignedInt'/ /attribute oneOrMore ref name='cpu'/ @@ -188,7 +189,7 @@ define name='cpu' element name='cpu' attribute name='id' -ref name='uint'/ +ref name='unsignedInt'/ /attribute /element /define @@ -238,13 +239,13 @@ define name='emulator' element name='emulator' -ref name='path'/ +ref name='absFilePath'/ /element /define define name='loader' element name='loader' -ref name='path'/ +ref name='absFilePath'/ /element /define @@ -367,39 +368,9 @@ /choice /define - -define name='positiveInteger' -data type='positiveInteger' -param name=pattern[0-9]+/param -/data -/define - -define name='uint' -data type='unsignedInt' -param name=pattern[0-9]+/param -/data -/define - -define name='path' -data type='string' -param name=pattern/[a-zA-Z0-9_\+\-/%]+/param -/data -/define - define name='featureName' data type='string' param name='pattern'[a-zA-Z0-9\-_]+/param /data /define - -define name=UUID -choice -data type=string -param name=pattern[a-fA-F0-9]{32}/param -/data -data type=string -param name=pattern[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}/param -/data -/choice -/define /grammar diff --git a/docs/schemas/interface.rng b/docs/schemas/interface.rng index 53fa18a..3984b63 100644 --- a/docs/schemas/interface.rng +++ b/docs/schemas/interface.rng @@ -183,12 +183,12 @@ choice element name=miimon !-- miimon frequency in ms -- -attribute name=freqref name=uint//attribute +attribute name=freqref name=unsignedInt//attribute optional -attribute name=downdelayref name=uint//attribute +attribute name=downdelayref name=unsignedInt//attribute /optional optional -attribute name=updelayref name=uint//attribute +attribute name=updelayref name=unsignedInt//attribute /optional optional !-- use_carrier -- @@ -203,7 +203,7 @@ /optional /element element name=arpmon -attribute name=intervalref name=uint//attribute +attribute name=intervalref name=unsignedInt//attribute attribute name=targetref name=ipv4Addr//attribute optional attribute name=validate @@ -252,7 +252,7 @@ define name=mtu optional element name=mtu -attribute name=sizeref name=uint//attribute +attribute name=sizeref name=unsignedInt//attribute /element /optional /define @@ -407,12 +407,6 @@ !-- Type library -- -define name='uint' -data type='unsignedInt' -param name=pattern[0-9]+/param -/data -/define - define name=timeval data type=double param name=minInclusive0/param diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 1b9a2d1..a73c2e5 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -1,6 +1,7 @@ !-- A Relax NG schema for the libvirt node device XML format -- grammar xmlns=http://relaxng.org/ns/structure/1.0; datatypeLibrary=http://www.w3.org/2001/XMLSchema-datatypes; +include href='basictypes.rng'/ start ref name='device'/ /start @@ -56,7 +57,7 @@ /optional element name='uuid' -ref name='uuid'/ +ref name='UUID'/ /element /element @@ -80,16 +81,16 @@ /attribute element name='domain' -ref name='uint'/ +ref name='unsignedLong'/ /element element name='bus' -ref name='uint'/ +ref name='unsignedLong'/ /element element name='slot'
Re: [libvirt] [PATCH] xml: Clean up schemas to use shared data types instead of local
On 03/06/2012 08:00 AM, Osier Yang wrote: On 2012年03月06日 22:15, Peter Krempa wrote: The schema files contained duplicate data types that can be shared from the basictypes.rng file. --- IIRC, unsignedLong allows the the + sign, and leading spaces, which we may not want. Actually, unsignedLong does not allow that; see https://www.redhat.com/archives/libvir-list/2012-March/msg00192.html which lets the libvirt definition be further restricted: + define name='unsignedLong' +data type='unsignedLong' + param name='pattern'[0-9]+/param +/data + /define Others looks good. I'm fine with the entire patch, although you probably need to wait to push it until I've pushed mine (since otherwise basictypes.rng won't have the unsignedLong definition). -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 05/15] xml: output memory unit for clarity
On 03/06/2012 01:34 AM, Eric Blake wrote: Make it obvious to 'dumpxml' readers what unit we are using, since our default of KiB for memory (1024) differs from qemu's default of MiB; while we use bytes for storage. Tests were updated via: $ find tests/*data tests/*out -name '*.xml' | \ xargs sed -i 's/\(memory\|currentMemory\|hard_limit\|soft_limit\|min_guarantee\|swap_hard_limit\)/\1 unit=''KiB'/ $ find tests/*data tests/*out -name '*.xml' | \ xargs sed -i 's/\(capacity\|allocation\|available\)/\1 unit=''bytes'/ followed by a few fixes for the stragglers. * docs/schemas/basictypes.rng (unit): Add 'bytes'. (scaledInteger): New define. * docs/schemas/storagevol.rng (sizing): Use it. * docs/schemas/storagepool.rng (sizing): Likewise. * docs/schemas/domaincommon.rng (memoryKBElement): New define; use for memory elements. * src/conf/storage_conf.c (virStoragePoolDefFormat) (virStorageVolDefFormat): Likewise. * src/conf/domain_conf.h (_virDomainDef): Document unit used internally. * src/conf/storage_conf.h (_virStoragePoolDef, _virStorageVolDef): Likewise. * tests/*data/*.xml: Update all tests. * tests/*out/*.xml: Likewise. * tests/define-dev-segfault: Likewise. * tests/openvzutilstest.c (testReadNetworkConf): Likewise. * tests/qemuargv2xmltest.c (blankProblemElements): Likewise. --- corresponds to memory v1 1/3; v2: also output units for storage, use 'unit=' not 'units=', use common RNG Portions of this patch elided to reduce mail size; see cover letter for git repo to see entire patch. I didn't read the cover letter thoroughly enough to notice the repo, at first :( diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 4f16fa7..a50349c 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -140,8 +140,16 @@ define name='unit' data type='string' -param name='pattern'[kKmMgGtTpPeE]/param +param name='pattern'(bytes)|[kKmMgGtTpPeE]/param Looking at this again. Don't you want to be able to specify the unit as KiB or just only as k? /data /define +define name='scaledInteger' +optional +attribute name='unit' +ref name='unit'/ +/attribute +/optional +ref name='unsignedLong'/ +/define /grammar diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9654f1..331d923 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11638,8 +11638,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, xmlIndentTreeOutput = oldIndentTreeOutput; } -virBufferAsprintf(buf, memory%lu/memory\n, def-mem.max_balloon); -virBufferAsprintf(buf, currentMemory%lu/currentMemory\n, +virBufferAsprintf(buf, memory unit='KiB'%lu/memory\n, + def-mem.max_balloon); +virBufferAsprintf(buf, currentMemory unit='KiB'%lu/currentMemory\n, def-mem.cur_balloon); I'm not quite sure about this. When we print the unit and somebody tries to use the xml as a template for a new machine or simply to change the memory allocation for the domain using virsh edit, he might be tempted to change the unit to mibibytes and expect the amount of memory to be used. Instead of that he will get that amount in kilobytes and no warning about this. We probably should parse the unit and at least warn the user about this happening. With this patch applied to current upstream you will need to: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml index 65cd55d..b6bf1d4 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml @@ -1,8 +1,8 @@ domain type='qemu' nameQEMUGuest1/name uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid - memory219136/memory - currentMemory219136/currentMemory + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory vcpu1/vcpu os type arch='i686' machine='pc'hvm/type to pass the tests. I'm not comfortable ACKing this one :(. I'd like to have some feedback from others on printing units without parsing them. Otherwise looks fine and passes the tests with that patch applied. Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 06/15] storage: support more scaling suffixes
On 03/06/2012 01:34 AM, Eric Blake wrote: Disk manufacturers are fond of quoting sizes in powers of 10, rather than powers of 2 (after all, 2.1 GB sounds larger than 2.0 GiB, even though the exact opposite is true). So, we might as well follow coreutils lead in supporting three types of suffix: single letter ${u} (which we already had) and ${u}iB for the power of 2, and ${u}B for power of 10. Additionally, it is impossible to create a file with more than 2**63 bytes, since off_t is signed (if you have enough storage to even create one 8EiB file, I'm jealous). This now reports failure up front rather than down the road when the kernel finally refuses an impossible size. * docs/schemas/basictypes.rng (unit): Add suffixes. * src/conf/storage_conf.c (virStorageSize): Use new function. * docs/formatstorage.html.in: Document it. --- v2: new docs/formatstorage.html.in | 21 +--- docs/schemas/basictypes.rng|2 +- src/conf/storage_conf.c| 61 +++- tests/storagevolxml2xmlin/vol-file-backing.xml |4 +- tests/storagevolxml2xmlin/vol-file.xml |4 +- 5 files changed, 26 insertions(+), 66 deletions(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 93d8ab2..b0acaf3 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -236,13 +236,20 @@ br/ By default this is specified in bytes, but an optional codeunit/code can be specified to adjust the passed value. -Values can be: 'K' (kibibytes, 2sup10/sup or 1024), 'M' -(mebibytes, 2sup20/sup or 1,048,576), 'G' (gibibytes, -2sup30/sup or 1,073,741,824), 'T' (tebibytes, -2sup40/sup or 1,099,511,627,776), 'P' (pebibytes, -2sup50/sup or 1,125,899,906,842,624), or 'E' (exbibytes, -2sup60/sup or 1,152,921,504,606,846,976). -span class=sinceSince 0.4.1/span/dd +Values can be: 'B' or 'bytes' for bytes, 'KB' (kilobytes, +10sup3/sup or 1000), 'K' or 'KiB' (kibibytes, +2sup10/sup or 1024), 'MB' (megabytes, 10sup6/sup or +1,000,000), 'M' or 'MiB' (mebibytes, 2sup20/sup or +1,048,576), 'GB' (gigabytes, 10sup9/sup or 1,000,000,000), +'G' or 'GiB' (gibibytes, 2sup30/sup or 1,073,741,824), As Christophe pointed out on 01/15, it would probably be better to state that the numbers are in bytes. +'TB' (terabytes, 10sup12/sup or 1,000,000,000,000), 'T' or +'TiB' (tebibytes, 2sup40/sup or 1,099,511,627,776), 'PB' +(petabytes, 10sup15/sup or 1,000,000,000,000,000), 'P' or +'PiB' (pebibytes, 2sup50/sup or 1,125,899,906,842,624), +'EB' (exabytes, 10sup18/sup or 1,000,000,000,000,000,000), +or 'E' or 'EiB' (exbibytes, 2sup60/sup or +1,152,921,504,606,846,976).span class=sinceSince 0.4.1, +multi-charactercodeunit/code since 0.9.11/span/dd dtcodecapacity/code/dt ddProviding the logical capacity for the volume. This value is in bytes by default, but acodeunit/code attribute can be diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index a50349c..cc0bc12 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -140,7 +140,7 @@ define name='unit' data type='string' -param name='pattern'(bytes)|[kKmMgGtTpPeE]/param +param name='pattern'([bB]([yY][tT][eE][sS]?)?)|([kKmMgGtTpPeE]([iI]?[bB])?)/param This makes the comment from the last patch obsolete. /data /define define name='scaledInteger' ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 07/15] xml: drop unenforced minimum memory limit from RNG
On 03/06/2012 01:34 AM, Eric Blake wrote: The test domain allowsmemory0/memory, but the RNG was stating that memory had to be at least 4096000 bytes. Hypervisors should enforce their own limits, rather than complicating the RNG. Meanwhile, some copy and paste had introduced some fishy constructs in various unit tests. * docs/schemas/domaincommon.rng (memoryKB, memoryKBElement): Drop limit that isn't enforced in code. * src/conf/domain_conf.c (virDomainDefParseXML): Require current = maximum. * tests/qemuxml2argvdata/*.xml: Fix offenders. --- ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 05/15] xml: output memory unit for clarity
On 03/06/2012 08:14 AM, Peter Krempa wrote: On 03/06/2012 01:34 AM, Eric Blake wrote: Make it obvious to 'dumpxml' readers what unit we are using, since our default of KiB for memory (1024) differs from qemu's default of MiB; while we use bytes for storage. Tests were updated via: +++ b/docs/schemas/basictypes.rng @@ -140,8 +140,16 @@ define name='unit' data type='string' -param name='pattern'[kKmMgGtTpPeE]/param +param name='pattern'(bytes)|[kKmMgGtTpPeE]/param Looking at this again. Don't you want to be able to specify the unit as KiB or just only as k? Yes, and that gets fixed later in the series (see 6/15 and 10/15). This was the minimum change to get 'make check' to pass at this stage of the series before I start adding new parsing abilities in later patches. Also, note that domaincommon.rng _isn't_ using ref name='unit'/ until patch 10/15; in this patch, domaincommon.rng is using an open-coded RNG that accepts _only_ attribute name='unit'valueKiB/value/attribute. -virBufferAsprintf(buf, currentMemory%lu/currentMemory\n, +virBufferAsprintf(buf, memory unit='KiB'%lu/memory\n, + def-mem.max_balloon); +virBufferAsprintf(buf, currentMemory unit='KiB'%lu/currentMemory\n, def-mem.cur_balloon); I'm not quite sure about this. When we print the unit and somebody tries to use the xml as a template for a new machine or simply to change the memory allocation for the domain using virsh edit, he might be tempted to change the unit to mibibytes and expect the amount of memory to be used. Instead of that he will get that amount in kilobytes and no warning about this. We probably should parse the unit and at least warn the user about this happening. Yes, that happens in 10/15. With this patch applied to current upstream you will need to: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml index 65cd55d..b6bf1d4 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml @@ -1,8 +1,8 @@ domain type='qemu' nameQEMUGuest1/name uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid - memory219136/memory - currentMemory219136/currentMemory + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory Ah, new tests added in the meantime. Yes, when I rebase, I'll make sure things still work. to pass the tests. I'm not comfortable ACKing this one :(. I'd like to have some feedback from others on printing units without parsing them. Otherwise looks fine and passes the tests with that patch applied. If anything, I can modify the commit message to mention that a later patch will parse units. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Build error on OSX in src/util/virnetlink.c
Hi, I'm building on OSX with no libnl. I had to do this to get src/util/virnetlink.c to compile: diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 1575bad..59f3e39 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -545,9 +545,9 @@ int virNetlinkCommand(struct nl_msg *nl_msg ATTRIBUTE_UNUSED, */ int virNetlinkEventServiceStop(void) { +# if defined(__linux__) !defined(HAVE_LIBNL) netlinkError(VIR_ERR_INTERNAL_ERROR, %s, -# if defined(__linux__) !defined(HAVE_LIBNL) _(virNetlinkEventServiceStop is not supported since libnl was not available)); # endif return 0; Cheers -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 08/15] xml: use long long internally, to centralize overflow checks
On 03/06/2012 01:34 AM, Eric Blake wrote: On 64-bit platforms, unsigned long and unsigned long long are identical, so we don't have to worry about overflow checks. On 32-bit platforms, anywhere we narrow unsigned long long back to unsigned long, we have to worry about overflow; it's easier to do this in one place by having most of the code use the same or wider types, and only doing the narrowing at the last minute. Therefore, the memory set commands remain unsigned long, and the memory get command now centralizes the overflow check into libvirt.c, so that drivers don't have to repeat the work. * src/driver.h (virDrvDomainGetMaxMemory): Use long long. * src/libvirt.c (virDomainGetMaxMemory): Raise overflow. * src/test/test_driver.c (testGetMaxMemory): Fix driver. * src/rpc/gendispatch.pl (name_to_ProcName): Likewise. * src/xen/xen_hypervisor.c (xenHypervisorGetMaxMemory): Likewise. * src/xen/xen_driver.c (xenUnifiedDomainGetMaxMemory): Likewise. * src/xen/xend_internal.c (xenDaemonDomainGetMaxMemory): Likewise. * src/xen/xend_internal.h (xenDaemonDomainGetMaxMemory): Likewise. * src/xen/xm_internal.c (xenXMDomainGetMaxMemory): Likewise. * src/xen/xm_internal.h (xenXMDomainGetMaxMemory): Likewise. * src/xen/xs_internal.c (xenStoreDomainGetMaxMemory): Likewise. * src/xen/xs_internal.h (xenStoreDomainGetMaxMemory): Likewise. * src/xenapi/xenapi_driver.c (xenapiDomainGetMaxMemory): Likewise. * src/esx/esx_driver.c (esxDomainGetMaxMemory): Likewise. * src/libxl/libxl_driver.c (libxlDomainGetMaxMemory): Likewise. * src/qemu/qemu_driver.c (qemudDomainGetMaxMemory): Likewise. * src/lxc/lxc_driver.c (lxcDomainGetMaxMemory): Likewise. * src/uml/uml_driver.c (umlDomainGetMaxMemory): Likewise. --- @@ -495,23 +495,23 @@ xenStoreDomainSetMemory(virDomainPtr domain, unsigned long memory) * * Returns the memory size in kilobytes or 0 in case of error. */ -unsigned long +unsigned long long xenStoreDomainGetMaxMemory(virDomainPtr domain) { char *tmp; -unsigned long ret = 0; +unsigned long long ret = 0; xenUnifiedPrivatePtr priv; if (!VIR_IS_CONNECTED_DOMAIN(domain)) return (ret); if (domain-id == -1) -return(-1); +return(0); This was scary! priv = domain-conn-privateData; xenUnifiedLock(priv); tmp = virDomainDoStoreQuery(domain-conn, domain-id, memory/target); if (tmp != NULL) { -ret = (unsigned long) atol(tmp); +ret = atol(tmp); VIR_FREE(tmp); } xenUnifiedUnlock(priv); ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Build error on OSX in src/util/virnetlink.c
On 03/06/2012 09:15 AM, Duncan Rance wrote: Hi, I'm building on OSX with no libnl. I had to do this to get src/util/virnetlink.c to compile: diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 1575bad..59f3e39 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -545,9 +545,9 @@ int virNetlinkCommand(struct nl_msg *nl_msg ATTRIBUTE_UNUSED, */ int virNetlinkEventServiceStop(void) { +# if defined(__linux__) !defined(HAVE_LIBNL) netlinkError(VIR_ERR_INTERNAL_ERROR, %s, -# if defined(__linux__) !defined(HAVE_LIBNL) _(virNetlinkEventServiceStop is not supported since libnl was not available)); Oops - that's a blatant bug. ACK and pushed. I've also added you to AUTHORS; let me know if you prefer an alternate spelling. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 09/15] xml: use better types for memory values
On 03/06/2012 01:34 AM, Eric Blake wrote: Using 'unsigned long' for memory values is risky on 32-bit platforms, as a PAE guest can have more than 4GiB memory. Our API is (unfortunately) locked at 'unsigned long' and a scale of 1024, but the rest of our system should consistently use 64-bit values, especially since the previous patch centralized overflow checking. * src/conf/domain_conf.h (_virDomainDef): Always use 64-bit values for memory. Change hugepage_backed to a bool. * src/conf/domain_conf.c (virDomainDefParseXML) (virDomainDefCheckABIStability, virDomainDefFormatInternal): Fix clients. * src/vmx/vmx.c (virVMXFormatConfig): Likewise. * src/xenxs/xen_sxpr.c (xenParseSxpr, xenFormatSxpr): Likewise. * src/xenxs/xen_xm.c (xenXMConfigGetULongLong): New function. (xenXMConfigGetULong, xenXMConfigSetInt): Avoid truncation. (xenParseXM, xenFormatXM): Fix clients. * src/phyp/phyp_driver.c (phypBuildLpar): Likewise. * src/openvz/openvz_driver.c (openvzDomainSetMemoryInternal): Likewise. * src/vbox/vbox_tmpl.c (vboxDomainDefineXML): Likewise. * src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise. * src/qemu/qemu_process.c (qemuProcessStart): Likewise. * src/qemu/qemu_monitor.h (qemuMonitorGetBalloonInfo): Likewise. * src/qemu/qemu_monitor_text.h (qemuMonitorTextGetBalloonInfo): Likewise. * src/qemu/qemu_monitor_text.c (qemuMonitorTextGetBalloonInfo): Likewise. * src/qemu/qemu_monitor_json.h (qemuMonitorJSONGetBalloonInfo): Likewise. * src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBalloonInfo): Likewise. * src/qemu/qemu_driver.c (qemudDomainGetInfo) (qemuDomainGetXMLDesc): Likewise. * src/uml/uml_conf.c (umlBuildCommandLine): Likewise. --- diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index f8390ea..beafb95 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -1101,9 +1133,15 @@ cleanup: static -int xenXMConfigSetInt(virConfPtr conf, const char *setting, long l) { +int xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l) { virConfValuePtr value = NULL; +if ((long) l != l) { +XENXS_ERROR(VIR_ERR_INTERNAL_ERROR, I suppose the VIR_ERR_INTERNAL_ERROR is intentional. +_(integer overflow in trying to store %lld to %s), +l, setting); +return -1; +} if (VIR_ALLOC(value) 0) { virReportOOMError(); return -1; ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 2/3] Add LibvirtGConfigDomainChardevSourceSpiceVmc
This is needed to be able to add the SPICE agent channels --- libvirt-gconfig/Makefile.am|2 + ...ibvirt-gconfig-domain-chardev-source-spicevmc.c | 80 ...ibvirt-gconfig-domain-chardev-source-spicevmc.h | 70 + libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|4 + libvirt-gconfig/tests/test-domain-create.c | 14 6 files changed, 171 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 03a5507..d9e87b5 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -17,6 +17,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-chardev.h \ libvirt-gconfig-domain-chardev-source.h \ libvirt-gconfig-domain-chardev-source-pty.h \ + libvirt-gconfig-domain-chardev-source-spicevmc.h \ libvirt-gconfig-domain-clock.h \ libvirt-gconfig-domain-console.h \ libvirt-gconfig-domain-device.h \ @@ -68,6 +69,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-chardev.c \ libvirt-gconfig-domain-chardev-source.c \ libvirt-gconfig-domain-chardev-source-pty.c \ + libvirt-gconfig-domain-chardev-source-spicevmc.c \ libvirt-gconfig-domain-clock.c \ libvirt-gconfig-domain-console.c \ libvirt-gconfig-domain-device.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c new file mode 100644 index 000..22eabf5 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c @@ -0,0 +1,80 @@ +/* + * libvirt-gconfig-domain-chardev-source-spicevmc.c: libvirt domain chardev spicevmc configuration + * + * Copyright (C) 2012 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@redhat.com + */ + +#include config.h + +#include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-private.h + +#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC, GVirConfigDomainChardevSourceSpiceVmcPrivate)) + +struct _GVirConfigDomainChardevSourceSpiceVmcPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainChardevSourceSpiceVmc, gvir_config_domain_chardev_source_spicevmc, GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE); + + +static void gvir_config_domain_chardev_source_spicevmc_class_init(GVirConfigDomainChardevSourceSpiceVmcClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDomainChardevSourceSpiceVmcPrivate)); +} + + +static void gvir_config_domain_chardev_source_spicevmc_init(GVirConfigDomainChardevSourceSpiceVmc *source) +{ +g_debug(Init GVirConfigDomainChardevSourceSpiceVmc=%p, source); + +source-priv = GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC_GET_PRIVATE(source); +} + + +GVirConfigDomainChardevSourceSpiceVmc *gvir_config_domain_chardev_source_spicevmc_new(void) +{ +GVirConfigObject *object; + +/* the name of the root node is just a placeholder, it will be + * overwritten when the GVirConfigDomainChardevSourceSpiceVmc is attached to a + * GVirConfigDomainChardevSourceSpiceVmc + */ +object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_CHARDEV_SOURCE_SPICE_VMC, dummy, NULL); +gvir_config_object_set_attribute(object, type, spicevmc, NULL); +return GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_SPICE_VMC(object); +} + + +GVirConfigDomainChardevSourceSpiceVmc *gvir_config_domain_chardev_source_spicevmc_new_from_xml(const gchar *xml, + GError **error) +{ +GVirConfigObject
[libvirt] [libvirt-glib 1/3] Fix GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_GUESTFWD name
It was called GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_GUESTFWD, which in turn confused glib-mkenums, leading to a wrong value being generated in the XML when trying to use this enumeration. --- libvirt-gconfig/libvirt-gconfig-domain-channel.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-channel.h b/libvirt-gconfig/libvirt-gconfig-domain-channel.h index a8a3020..5141d11 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-channel.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-channel.h @@ -57,7 +57,7 @@ struct _GVirConfigDomainChannelClass }; typedef enum { -GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_GUESTFWD, +GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_GUESTFWD, GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_VIRTIO, } GVirConfigDomainChannelTargetType; -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 3/3] Add GVirConfigDomainRedirdev
This is used to add the SPICE USB redirection channel. Even if the libvirt doc doesn't document it with the other devices deriving from GVirConfigDomainChardev, I think it makes sense to have this class derivers from GVirConfigDomainChardev too since it needs a GVirConfigDomainChardevSource, and it's documented as using a character device for redirection. --- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-domain-redirdev.c | 82 + libvirt-gconfig/libvirt-gconfig-domain-redirdev.h | 73 ++ libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym |6 ++ libvirt-gconfig/tests/test-domain-create.c| 14 6 files changed, 178 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-redirdev.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-redirdev.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index d9e87b5..181ec57 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -35,6 +35,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-memballoon.h \ libvirt-gconfig-domain-os.h \ libvirt-gconfig-domain-parallel.h \ + libvirt-gconfig-domain-redirdev.h \ libvirt-gconfig-domain-seclabel.h \ libvirt-gconfig-domain-serial.h \ libvirt-gconfig-domain-snapshot.h \ @@ -87,6 +88,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-memballoon.c \ libvirt-gconfig-domain-os.c \ libvirt-gconfig-domain-parallel.c \ + libvirt-gconfig-domain-redirdev.c \ libvirt-gconfig-domain-seclabel.c \ libvirt-gconfig-domain-serial.c \ libvirt-gconfig-domain-snapshot.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c new file mode 100644 index 000..30c370a --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c @@ -0,0 +1,82 @@ +/* + * libvirt-gconfig-domain-redirdev.c: libvirt domain redirdev configuration + * + * Copyright (C) 2012 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@redhat.com + */ + +#include config.h + +#include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-private.h + +#define GVIR_CONFIG_DOMAIN_REDIRDEV_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, GVirConfigDomainRedirdevPrivate)) + +struct _GVirConfigDomainRedirdevPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDomainRedirdev, gvir_config_domain_redirdev, GVIR_CONFIG_TYPE_DOMAIN_CHARDEV); + + +static void gvir_config_domain_redirdev_class_init(GVirConfigDomainRedirdevClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDomainRedirdevPrivate)); +} + + +static void gvir_config_domain_redirdev_init(GVirConfigDomainRedirdev *redirdev) +{ +g_debug(Init GVirConfigDomainRedirdev=%p, redirdev); + +redirdev-priv = GVIR_CONFIG_DOMAIN_REDIRDEV_GET_PRIVATE(redirdev); +} + + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, +redirdev, NULL); +return GVIR_CONFIG_DOMAIN_REDIRDEV(object); +} + +GVirConfigDomainRedirdev *gvir_config_domain_redirdev_new_from_xml(const gchar *xml, + GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV, + redirdev, NULL, xml, error); +return GVIR_CONFIG_DOMAIN_REDIRDEV(object); +} + +void gvir_config_domain_redirdev_set_bus(GVirConfigDomainRedirdev *redirdev, + GVirConfigDomainRedirdevBus bus) +{ +
Re: [libvirt] [libvirt-glib 1/3] Fix GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_GUESTFWD name
On Tue, Mar 6, 2012 at 6:38 PM, Christophe Fergeau cferg...@redhat.com wrote: It was called GVIR_CONFIG_DOMAIN_CONSOLE_TARGET_GUESTFWD, which in turn confused glib-mkenums, leading to a wrong value being generated in the XML when trying to use this enumeration. ACK! -- Regards, Zeeshan Ali (Khattak) FSF member#5124 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] rpc: Fix VPATH building issue
The XDR routine .c file generated by rpcgen includes the corresponding Header file. however, the path in include directive of the header file is picked up based on the path of .x file. In the situation of VPATH Builds it will include full path of the header file rather than relative path. Hence, the error happens when compiling time For example: The libvirt source code resides in /home/testuser, I make dist in /tmp/buildvpath, the XDR routine .c file will include full path of the header file like: #include /home/testuser/src/rpc/virnetprotocol.h #include internal.h #include arpa/inet.h If we distribute the tarball to another machine to compile, it will report error as follows: rpc/virnetprotocol.c:7:59: fatal error: /home/testuser/src/rpc/virnetprotocol.h: No such file or directory --- src/Makefile.am | 14 ++ 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index e57eca2..6c9f598 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -662,12 +662,18 @@ $(srcdir)/remote/remote_driver.c: $(REMOTE_DRIVER_GENERATED) endif WITH_REMOTE %protocol.c: %protocol.x %protocol.h $(srcdir)/rpc/genprotocol.pl - $(AM_V_GEN)perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -c \ - $ $@ + $(AM_V_GEN)protocolx='$'; \ + protocolc='$@'; \ + cd $(srcdir); \ + perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -c \ + $${protocolx/'$(srcdir)/'/''} $${protocolc/'$(srcdir)/'/''} %protocol.h: %protocol.x $(srcdir)/rpc/genprotocol.pl - $(AM_V_GEN)perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -h \ - $ $@ + $(AM_V_GEN)protocolx='$'; \ + protocolh='$@'; \ + cd $(srcdir); \ + perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -h \ + $${protocolx/'$(srcdir)/'/''} $${protocolh/'$(srcdir)/'/''} if WITH_XEN if WITH_DRIVER_MODULES -- 1.7.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 10/15] xml: allow scaled memory on input
On 03/06/2012 01:34 AM, Eric Blake wrote: Output is still in kibibytes, but input can now be in different scales for ease of typing. * src/conf/domain_conf.c (virDomainParseMemory): New helper. (virDomainDefParseXML): Use it when parsing. * docs/schemas/domaincommon.rng: Expand XML; rename memoryKBElement to memoryElement and update callers. * docs/formatdomain.html.in (elementsMemoryAllocation): Document scaling. * tests/qemuxml2argvdata/qemuxml2argv-memtune.xml: Adjust test. * tests/qemuxml2xmltest.c: Likewise. * tests/qemuxml2xmloutdata/qemuxml2xmlout-memtune.xml: New file. --- v2: reuse code introduced earlier in series, add tests docs/formatdomain.html.in | 42 +++-- docs/schemas/domaincommon.rng | 23 ++ src/conf/domain_conf.c | 93 +++ tests/qemuxml2argvdata/qemuxml2argv-memtune.xml|6 +- .../qemuxml2xmloutdata/qemuxml2xmlout-memtune.xml | 31 +++ tests/qemuxml2xmltest.c|2 +- 6 files changed, 147 insertions(+), 50 deletions(-) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-memtune.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0855c7f..1e4a990 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -415,8 +415,8 @@ pre lt;domaingt; ... -lt;memorygt;524288lt;/memorygt; -lt;currentMemorygt;524288lt;/currentMemorygt; +lt;memory unit='KiB'gt;524288lt;/memorygt; +lt;currentMemory unit='KiB'gt;524288lt;/currentMemorygt; ... lt;/domaingt; /pre @@ -424,12 +424,30 @@ dl dtcodememory/code/dt ddThe maximum allocation of memory for the guest at boot time. -The units for this value are kibibytes (i.e. blocks of 1024 bytes)/dd +The units for this value are determined by the optional +atttributecodeunit/code, which defaults to KiB +(kibibytes, 2sup10/sup or blocks of 1024 bytes). Valid +units are b or bytes for bytes, KB for kilobytes +(10sup3/sup or 1,000), k or KiB for kibibytes (1024), +MB for megabytes (10sup6/sup or 1,000,000), M or MiB +for mebibytes (2sup20/sup or 1,048,576), GB for As in the previous similar sections, I'd explicitly specify that the numbers are bytes here. +gigabytes (10sup9/sup or 1,000,000,000), G or GiB for +gibibytes (2sup30/sup or 1,073,741,824), TB for +terabytes (10sup12/sup or 1,000,000,000,000), or T or +TiB for tebibytes (2sup40/sup or 1,099,511,627,776). +However, the value will be rounded up to the nearest kibibyte +by libvirt, and may be further rounded to the granularity +supported by the hypervisor. Some hypervisors also enforce a +minimum, such as This patch clears everything I was afraid in 05/15. ACK, Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 05/15] xml: output memory unit for clarity
On 03/06/2012 04:14 PM, Peter Krempa wrote: On 03/06/2012 01:34 AM, Eric Blake wrote: Make it obvious to 'dumpxml' readers what unit we are using, since our default of KiB for memory (1024) differs from qemu's default of MiB; while we use bytes for storage. Tests were updated via: $ find tests/*data tests/*out -name '*.xml' | \ xargs sed -i 's/\(memory\|currentMemory\|hard_limit\|soft_limit\|min_guarantee\|swap_hard_limit\)/\1 unit=''KiB'/ $ find tests/*data tests/*out -name '*.xml' | \ xargs sed -i 's/\(capacity\|allocation\|available\)/\1 unit=''bytes'/ followed by a few fixes for the stragglers. * docs/schemas/basictypes.rng (unit): Add 'bytes'. (scaledInteger): New define. * docs/schemas/storagevol.rng (sizing): Use it. * docs/schemas/storagepool.rng (sizing): Likewise. * docs/schemas/domaincommon.rng (memoryKBElement): New define; use for memory elements. * src/conf/storage_conf.c (virStoragePoolDefFormat) (virStorageVolDefFormat): Likewise. * src/conf/domain_conf.h (_virDomainDef): Document unit used internally. * src/conf/storage_conf.h (_virStoragePoolDef, _virStorageVolDef): Likewise. * tests/*data/*.xml: Update all tests. * tests/*out/*.xml: Likewise. * tests/define-dev-segfault: Likewise. * tests/openvzutilstest.c (testReadNetworkConf): Likewise. * tests/qemuargv2xmltest.c (blankProblemElements): Likewise. --- corresponds to memory v1 1/3; v2: also output units for storage, use 'unit=' not 'units=', use common RNG Portions of this patch elided to reduce mail size; see cover letter for git repo to see entire patch. I didn't read the cover letter thoroughly enough to notice the repo, at first :( diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 4f16fa7..a50349c 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -140,8 +140,16 @@ define name='unit' data type='string' -param name='pattern'[kKmMgGtTpPeE]/param +param name='pattern'(bytes)|[kKmMgGtTpPeE]/param Looking at this again. Don't you want to be able to specify the unit as KiB or just only as k? /data /define +define name='scaledInteger' +optional +attribute name='unit' +ref name='unit'/ +/attribute +/optional +ref name='unsignedLong'/ +/define /grammar diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9654f1..331d923 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11638,8 +11638,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, xmlIndentTreeOutput = oldIndentTreeOutput; } - virBufferAsprintf(buf, memory%lu/memory\n, def-mem.max_balloon); - virBufferAsprintf(buf, currentMemory%lu/currentMemory\n, + virBufferAsprintf(buf, memory unit='KiB'%lu/memory\n, + def-mem.max_balloon); + virBufferAsprintf(buf, currentMemory unit='KiB'%lu/currentMemory\n, def-mem.cur_balloon); I'm not quite sure about this. When we print the unit and somebody tries to use the xml as a template for a new machine or simply to change the memory allocation for the domain using virsh edit, he might be tempted to change the unit to mibibytes and expect the amount of memory to be used. Instead of that he will get that amount in kilobytes and no warning about this. We probably should parse the unit and at least warn the user about this happening. With this patch applied to current upstream you will need to: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml index 65cd55d..b6bf1d4 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml @@ -1,8 +1,8 @@ domain type='qemu' nameQEMUGuest1/name uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid - memory219136/memory - currentMemory219136/currentMemory + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory vcpu1/vcpu os type arch='i686' machine='pc'hvm/type to pass the tests. I'm not comfortable ACKing this one :(. I'd like to have some feedback from others on printing units without parsing them. Otherwise looks fine and passes the tests with that patch applied. Peter After reviewing 10/15 I'm now comfortable with ACKing this one if 10/15 gets in :) Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] add screendump async to qemu
On 03/06/2012 04:02 AM, Alon Levy wrote: RHBZ: 800338 Adds a new capability to qemu, QEMU_CAPS_SCREENDUMP_ASYNC, available if the qmp command screendump-async exists. If that cap exists qemuDomainScreenshot uses it. The implementation consists of a hash from filename to struct holding the stream and temporary fd. The fd is closed and the stream is written to (in reverse order) by the completion callback, qemuProcessScreenshotComplete. Note: in qemuDomainScreenshot I don't check for an existing entry in the screenshots hash table because we the key is a temporary filename, produced by mkstemp, and it's only unlinked at qemuProcessScreenshotComplete. For testing you need to apply the following patches (they are still pending review on qemu-devel): http://patchwork.ozlabs.org/patch/144706/ http://patchwork.ozlabs.org/patch/144705/ http://patchwork.ozlabs.org/patch/144704/ Assuming qemu doesn't make any last-minute changes to the naming of the new command and format of the new event, then this patch looks reasonable. I'm reluctant to push it upstream until we know for sure that qemu is committed to the interface, though. And we need a v2 to fix the bugs below. +++ b/src/qemu/qemu_domain.c @@ -181,6 +181,10 @@ qemuDomainObjFreeJob(qemuDomainObjPrivatePtr priv) ignore_value(virCondDestroy(priv-job.asyncCond)); } +static void +freeScreenshot(void *payload, const void *name ATTRIBUTE_UNUSED) { +VIR_FREE(payload); +} static void *qemuDomainObjPrivateAlloc(void) { @@ -196,6 +200,8 @@ static void *qemuDomainObjPrivateAlloc(void) goto error; priv-migMaxBandwidth = QEMU_DOMAIN_DEFAULT_MIG_BANDWIDTH_MAX; +priv-screenshots = virHashCreate(QEMU_DOMAIN_SCREENSHOTS_CONCURRENT_MAX, + freeScreenshot); Missing a counterpart virHashFree(priv-screenshots) in qemuDomainObjPrivateFree. +++ b/src/qemu/qemu_driver.c @@ -3135,6 +3135,7 @@ qemuDomainScreenshot(virDomainPtr dom, int tmp_fd = -1; char *ret = NULL; bool unlink_tmp = false; +qemuScreenshotAsync *screenshot; Assign this to NULL... virCheckFlags(0, NULL); @@ -3184,9 +3185,34 @@ qemuDomainScreenshot(virDomainPtr dom, virSecurityManagerSetSavedStateLabel(qemu_driver-securityManager, vm-def, tmp); qemuDomainObjEnterMonitor(driver, vm); -if (qemuMonitorScreendump(priv-mon, tmp) 0) { -qemuDomainObjExitMonitor(driver, vm); -goto endjob; +if (qemuCapsGet(priv-qemuCaps, QEMU_CAPS_SCREENDUMP_ASYNC)) { +if (virHashSize(priv-screenshots) = +QEMU_DOMAIN_SCREENSHOTS_CONCURRENT_MAX) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, VIR_ERR_OPERATION_INVALID - the failure is transient and related to the state of the rest of libvirt, and not an internal error. +%s, _(too many ongoing screenshots)); +goto endjob; +} +if (VIR_ALLOC(screenshot) 0) { +qemuReportError(VIR_ERR_NO_MEMORY, %s, _(out of memory)); virReportOOMError() (it's almost always wrong to directly report VIR_ERR_NO_MEMORY; the helper function exists for a reason, since it can bypass some of the malloc's used in direct reporting, for a higher chance of success at actually reporting the error without tripping up on additional OOM situations.) +goto endjob; +} +screenshot-fd = tmp_fd; +screenshot-filename = tmp; +screenshot-stream = st; +virHashAddEntry(priv-screenshots, tmp, screenshot); +if (qemuMonitorScreendumpAsync(priv-mon, tmp) 0) { +qemuDomainObjExitMonitor(driver, vm); +goto endjob; ...and add VIR_FREE(screenshot) somewhere in the endjob label, otherwise, this failure path will leak memory. @@ -725,6 +727,16 @@ out: qemuMonitorEmitBlockJob(mon, device, type, status); } +static void qemuMonitorJSONHandleScreenDumpComplete(qemuMonitorPtr mon, +virJSONValuePtr data) +{ +const char *filename; + +if ((filename = virJSONValueObjectGetString(data, filename)) == NULL) { +VIR_WARN(missing filename in screen dump complete event); +} +qemuMonitorEmitScreenDumpComplete(mon, filename); Is it safe to call qemuMonitorEmitScreenDumpComplete with filename of NULL, or should this be in an else clause?... +++ b/src/qemu/qemu_process.c @@ -47,6 +47,7 @@ #include datatypes.h #include logging.h +#include fdstream.h #include virterror_internal.h #include memory.h #include hooks.h @@ -918,6 +919,33 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED, } static int +qemuProcessScreenshotComplete(qemuMonitorPtr mon ATTRIBUTE_UNUSED, + virDomainObjPtr vm, + const char *filename) +{ +qemuDomainObjPrivatePtr priv = vm-privateData; +
Re: [libvirt] [PATCHv2 11/15] virsh: add option aliases
On 03/06/2012 01:34 AM, Eric Blake wrote: In the past, we have created some virsh options with less-than-stellar names. For back-compat reasons, those names must continue to parse, but we don't want to document them in help output. This introduces a new option type, an alias, which points to a canonical option name later in the option list. I'm actually quite impressed that our code has already been factored to do all option parsing through common entry points, such that I got this added in relatively few lines of code! * tools/virsh.c (VSH_OT_ALIAS): New option type. (opts_echo): Hook up an alias, for easy testing. (vshCmddefOptParse, vshCmddefHelp, vshCmddefGetOption): Allow for aliases. * tests/virshtest.c (mymain): Test new feature. --- Nice way to mask old mistakes and still support them. I'm wondering if this will not confuse people if their beloved arguments disappear suddenly from the docs. Maybe the help command could explicitly state aliases that exist for commands to avoid some confusion. I'm leaning towards an ACK as it's better to encourage to use the fixed spelling. Does anyone object? Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 12/15] virsh: use option aliases
On 03/06/2012 01:34 AM, Eric Blake wrote: Command line interfaces should use dash, not underscore, as many keyboard layouts allow that to be typed with fewer shift key presses. Also, the US spelling of --tunneled gets more google hits than the UK spelling of --tunnelled. * tools/virsh.c (opts_migrate): Allow US variant. (opts_blkdeviotune): Prefer - over _. * tools/virsh.pod (blkdeviotune): Fix spelling. --- ACK Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 wait-for-qemu] add screendump async to qemu
RHBZ: 800338 Adds a new capability to qemu, QEMU_CAPS_SCREENDUMP_ASYNC, available if the qmp command screendump-async exists. If that cap exists qemuDomainScreenshot uses it. The implementation consists of a hash from filename to struct holding the stream and temporary fd. The fd is closed and the stream is written to (in reverse order) by the completion callback, qemuProcessScreenshotComplete. Note: in qemuDomainScreenshot I don't check for an existing entry in the screenshots hash table because we the key is a temporary filename, produced by mkstemp, and it's only unlinked at qemuProcessScreenshotComplete. For testing you need to apply the following patches (they are still pending review on qemu-devel): http://patchwork.ozlabs.org/patch/144706/ http://patchwork.ozlabs.org/patch/144705/ http://patchwork.ozlabs.org/patch/144704/ Signed-off-by: Alon Levy al...@redhat.com v2 changes: * v1 missed unlink of temp file on completion callback. * review issues from Eric Blake addressed: * virHashFree * screenshot free * s/VIR_ERR_INTERNAL_ERROR/VIR_ERR_OPERATION_INVALID/ * virReportOOMError * check for NULL filename in qemuProcessScreenshotComplete. --- src/qemu/qemu_capabilities.c |1 + src/qemu/qemu_capabilities.h |1 + src/qemu/qemu_domain.c |7 ++ src/qemu/qemu_domain.h | 12 +++ src/qemu/qemu_driver.c | 43 +++-- src/qemu/qemu_monitor.c | 26 + src/qemu/qemu_monitor.h |8 +++ src/qemu/qemu_monitor_json.c | 39 ++ src/qemu/qemu_monitor_json.h |3 ++ src/qemu/qemu_process.c | 30 + 10 files changed, 163 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 64a4546..57771ff 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -154,6 +154,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, drive-iotune, /* 85 */ system_wakeup, scsi-disk.channel, + screendump-async, ); struct qemu_feature_flags { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index db584ce..24d620d 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -122,6 +122,7 @@ enum qemuCapsFlags { QEMU_CAPS_DRIVE_IOTUNE = 85, /* -drive bps= and friends */ QEMU_CAPS_WAKEUP = 86, /* system_wakeup monitor command */ QEMU_CAPS_SCSI_DISK_CHANNEL = 87, /* Is scsi-disk.channel available? */ +QEMU_CAPS_SCREENDUMP_ASYNC = 88, /* screendump-async qmp command */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2fed91e..0c18d12 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -181,6 +181,10 @@ qemuDomainObjFreeJob(qemuDomainObjPrivatePtr priv) ignore_value(virCondDestroy(priv-job.asyncCond)); } +static void +freeScreenshot(void *payload, const void *name ATTRIBUTE_UNUSED) { +VIR_FREE(payload); +} static void *qemuDomainObjPrivateAlloc(void) { @@ -196,6 +200,8 @@ static void *qemuDomainObjPrivateAlloc(void) goto error; priv-migMaxBandwidth = QEMU_DOMAIN_DEFAULT_MIG_BANDWIDTH_MAX; +priv-screenshots = virHashCreate(QEMU_DOMAIN_SCREENSHOTS_CONCURRENT_MAX, + freeScreenshot); return priv; @@ -218,6 +224,7 @@ static void qemuDomainObjPrivateFree(void *data) VIR_FREE(priv-origname); virConsoleFree(priv-cons); +virHashFree(priv-screenshots); /* This should never be non-NULL if we get here, but just in case... */ if (priv-mon) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 1333d8c..15721ec 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -40,6 +40,8 @@ # define QEMU_DOMAIN_DEFAULT_MIG_BANDWIDTH_MAX 32 +# define QEMU_DOMAIN_SCREENSHOTS_CONCURRENT_MAX 16 + # define JOB_MASK(job) (1 (job - 1)) # define DEFAULT_JOB_MASK \ (JOB_MASK(QEMU_JOB_QUERY) | \ @@ -91,6 +93,14 @@ struct qemuDomainJobObj { virDomainJobInfo info; /* Async job progress data */ }; +struct _qemuScreenshotAsync { +virStreamPtr stream;/* stream to write results to */ +const char *filename; /* temporary file to read results from */ +int fd; /* handle to open temporary file */ +}; +typedef struct _qemuScreenshotAsync qemuScreenshotAsync; +typedef qemuScreenshotAsync *qemuScreenshotAsyncPtr; + typedef struct _qemuDomainPCIAddressSet qemuDomainPCIAddressSet; typedef qemuDomainPCIAddressSet *qemuDomainPCIAddressSetPtr; @@ -130,6 +140,8 @@ struct _qemuDomainObjPrivate { char *origname; virConsolesPtr cons; + +virHashTablePtr screenshots; };
[libvirt] Qemu, libvirt, and CPU models
Hi, Sorry for the long message, but I didn't find a way to summarize the questions and issues and make it shorter. For people who don't know me: I have started to work recently on the Qemu CPU model code. I have been looking at how things work on libvirt+Qemu today w.r.t. CPU models, and I have some points I would like to understand better and see if they can be improved. I have two main points I would like to understand/discuss: 1) The relationship between libvirt's cpu_map.xml and the Qemu CPU model definitions. 2) How we could properly allow CPU models to be changed without breaking existing virtual machines? Note that for all the questions below, I don't expect that we design the whole solution and discuss every single detail in this thread. I just want to collectn suggestions, information about libvirt requirements and assumptions, and warnings about expected pitfalls before I start working on a solution on Qemu. 1) Qemu and cpu_map.xml I would like to understand how cpu_map.xml is supposed to be used, and how it is supposed to interact with the CPU model definitions provided by Qemu. More precisely: 1.1) Do we want to eliminate the duplication between the Qemu CPU definitions and cpu_map.xml? 1.1.1) If we want to eliminate the duplication, how can we accomplish that? What interfaces you miss, that Qemu could provide? 1.1.2) If the duplication has a purpose and you want to keep cpu_map.xml, then: - First, I would like to understand why libvirt needs cpu_map.xml? Is it part of the public interface of libvirt, or is it just an internal file where libvirt stores non-user-visible data? - How can we make sure there is no confusion between libvirt and Qemu about the CPU models? For example, what if cpu_map.xml says model 'Moo' has the flag 'foo' enabled, but Qemu disagrees? How do we guarantee that libvirt gets exactly what it expects from Qemu when it asks for a CPU model? We have -cpu ?dump today, but it's not the better interface we could have. Do you miss something in special in the Qemu-libvirt interface, to help on that? 1.2) About the probing of available features on the host system: Qemu has code specialized to query KVM about the available features, and to check what can be enabled and what can't be enabled in a VM. On many cases, the available features match exactly what is returned by the CPUID instruction on the host system, but there are some exceptions: - Some features can be enabled even when the host CPU doesn't support it (because they are completely emulated by KVM, e.g. x2apic). - On many other cases, the feature may be available but we have to check if Qemu+KVM are really able to expose it to the guest (many features work this way, as many depend on specific support by the KVM kernel module and/or Qemu). I suppose libvirt does want to check which flags can be enabled in a VM, as it already have checks for host CPU features (e.g. src/cpu/cpu_x86.c:x86Compute()). But I also suppose that libvirt doesn't want to duplicate the KVM feature probing code present on Qemu, and in this case we could have an interface where libvirt could query for the actually-available CPU features. Would it be useful for libvirt? What's the best way to expose this interface? 1.3) Some features are not plain CPU feature bits: e.g. level=X can be set in -cpu argument, and other features are enabled/disabled by exposing specific CPUID leafs and not just a feature bit (e.g. PMU CPUID leaf support). I suppose libvirt wants to be able to probe for those features too, and be able to enable/disable them, right? 2) How to change an existing model and keep existing VMs working? Sometimes we have to update a CPU model definition because of some bug. Eamples: - The CPU models Conroe, Penrym and Nehalem, have level=2 set. This works most times, but it breaks CPU core/thread topology enumeration. We have to change those CPU models to use level=4 to fix the bug. - This can happen with plain CPU feature bits, too, not just level: sometimes real-world CPU models have a feature that is not supported by Qemu+KVM yet, but when the kernel and Qemu finally starts to support it, we may want to enable it on existing CPU models. Sometimes a model simply has the wrong set of feature bits, and we have to fix it to have the right set of features. But if we simply change the existing model definition, this will break existing machines: - Today, it would break on live migration, but that's slightly easy to fix: we have to migrate the CPUID information too, to make sure we won't change the CPU under the guest OS feet. - Even if we fix live migration, simple cold migration will make the guest OS see a different CPU after a reboot, and that's undesirable too. Even if the Qemu developers disagree with me and decide that this is not a problem, libvirt may want to expose a more stable CPU to the
Re: [libvirt] [PATCH] rpc: Fix VPATH building issue
On 03/06/2012 10:07 AM, Guannan Ren wrote: The XDR routine .c file generated by rpcgen includes the corresponding Header file. however, the path in include directive of the header file is picked up based on the path of .x file. In the situation of VPATH Builds it will include full path of the header file rather than relative path. Hence, the error happens when compiling time For example: The libvirt source code resides in /home/testuser, I make dist in /tmp/buildvpath, the XDR routine .c file will include full path of the header file like: #include /home/testuser/src/rpc/virnetprotocol.h #include internal.h #include arpa/inet.h If we distribute the tarball to another machine to compile, it will report error as follows: rpc/virnetprotocol.c:7:59: fatal error: /home/testuser/src/rpc/virnetprotocol.h: No such file or directory Previously, we've fixed this in genprotocol.pl, via lines like this: s,#include .*remote/remote_protocol\.h,#include remote_protocol.h,; I'm wondering whether it is better to fix it there for all protocol files. --- src/Makefile.am | 14 ++ 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index e57eca2..6c9f598 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -662,12 +662,18 @@ $(srcdir)/remote/remote_driver.c: $(REMOTE_DRIVER_GENERATED) endif WITH_REMOTE %protocol.c: %protocol.x %protocol.h $(srcdir)/rpc/genprotocol.pl - $(AM_V_GEN)perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -c \ -$ $@ + $(AM_V_GEN)protocolx='$'; \ + protocolc='$@'; \ + cd $(srcdir); \ + perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -c \ + $${protocolx/'$(srcdir)/'/''} $${protocolc/'$(srcdir)/'/''} Alas, ${foo/pat/sub} is not POSIX, so we cannot use it (if /bin/sh is dash, as is the case on Debian, then this is broken). But no fear, we _do_ require GNU make, so we can use $(patsubst pat,subst,foo) instead of $${foo/pat/sub}, if we still like the approach of changing Makefile.am rather than fixing genprotocol.pl. So, given that background, what do you think of this alternative patch? From 0ec1071294c3b02c6c77df4c61cb6f039bba Mon Sep 17 00:00:00 2001 From: Eric Blake ebl...@redhat.com Date: Tue, 6 Mar 2012 13:49:53 -0700 Subject: [PATCH] rpc: generalize solution for VPATH builds Commit 5d4b0c4c80 tried to fix certain classes of VPATH builds, but was too limited. In particular, Guannan Ren reported: For example: The libvirt source code resides in /home/testuser, I make dist in /tmp/buildvpath, the XDR routine .c file will include full path of the header file like: #include /home/testuser/src/rpc/virnetprotocol.h #include internal.h #include arpa/inet.h If we distribute the tarball to another machine to compile, it will report error as follows: rpc/virnetprotocol.c:7:59: fatal error: /home/testuser/src/rpc/virnetprotocol.h: No such file or directory * src/rpc/genprotocol.pl: Fix more include lines. --- src/rpc/genprotocol.pl |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl index 4838325..f8e68f5 100755 --- a/src/rpc/genprotocol.pl +++ b/src/rpc/genprotocol.pl @@ -8,7 +8,7 @@ # actually fixes for 64 bit, so this file is necessary. Arguably # so is the type-punning fix. # -# Copyright (C) 2007, 2011 Red Hat, Inc. +# Copyright (C) 2007, 2011-2012 Red Hat, Inc. # # See COPYING for the license of this software. # @@ -53,13 +53,15 @@ while (RPCGEN) { s/\t//g; +# Fix VPATH builds +s,#include .*/([^/]+)protocol\.h,#include ${1}protocol.h,; + # Portability for Solaris RPC s/u_quad_t/uint64_t/g; s/quad_t/int64_t/g; s/xdr_u_quad_t/xdr_uint64_t/g; s/xdr_quad_t/xdr_int64_t/g; s/(?!IXDR_GET_INT32 )IXDR_GET_LONG/IXDR_GET_INT32/g; -s,#include .*remote/remote_protocol\.h,#include remote_protocol.h,; if (m/^}/) { $in_function = 0; -- 1.7.7.6 -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RFC]: Support numad
I think numad will probably work best with just the #vcpus and the #MBs of memory in the guest as the requested job size parameters. Sorry for lack of clarity here... Numad should work -- pending bugs -- with any numbers passed. If the requested parameters are bigger than actual physical resources available, numad is supposed to just return all the nodes in the system -- so the effective recommendation in that case would be use the entire system. If the requested resources are a subset of the system, numad is supposed to return a recommended subset of the system nodes to use for the process -- based on the current amount of free memory and idle CPUs on the various nodes. On 03/01/2012 02:31 PM, Dave Allan wrote: On Wed, Feb 29, 2012 at 06:29:55AM -0500, Bill Burns wrote: On 02/28/2012 11:34 PM, Osier Yang wrote: On 02/29/2012 12:40 AM, Daniel P. Berrange wrote: On Tue, Feb 28, 2012 at 11:33:03AM -0500, Dave Allan wrote: On Tue, Feb 28, 2012 at 10:10:50PM +0800, Osier Yang wrote: numad is an user-level daemon that monitors NUMA topology and processes resource consumption to facilitate good NUMA resource alignment of applications/virtual machines to improve performance and minimize cost of remote memory latencies. It provides a pre-placement advisory interface, so significant processes can be pre-bound to nodes with sufficient available resources. More details: http://fedoraproject.org/wiki/Features/numad numad -w ncpus:memory_amount is the advisory interface numad provides currently. This patch add the support by introducing new XML like: numatune cpu required_cpus=4 required_memory=524288/ /numatune Isn't the usual case going to be the vcpus and memory in the guest? IMO we should default to passing those numbers to numad if required_cpus and required_memory are not provided explicitly. Indeed, why you would want to specify anything different ? At first glance my reaction was just skip the XML and call numad internally automatically with the guest configured allocation Here the required_cpus stands for the physical CPUs number, which will be used numad to choose the proper nodeset. So from sementics point of view, it's different withvcpus4/vcpus, I can imagine two problems if we reuse the vCPUs number for numad's use: 1) Suppose there are 16 pCPUs, but the specified vCPUs number is 64. I'm not sure if numad will work properly in this case, but isn't it a bad use case? :-) 2) Suppose there are 128 pCPUs, but the specified vCPUs number is 2. numad will work definitely, but is that the result the user wants to see? no good to performace. The basic thought is we provide the interface, and how to configure the provided XML for good performace is on the end-user then. If we mixed-use the two different sementics, and do things secrectly in the codes, then I could imagine there will be performance problems. The required_memory could be omitted though, we can reuse memory524288/memory, but I'm not sure if it's good to always pass a memory amount to numad command line, it may be not good in some case. @Bill(s), correct me if I'm not right. :-) Perhaps we could have a bool attribute then, such as: cpu required_cpus=4 required_memory=yes|no/ Please keep Bill Gray on this thread. He is the author of numad and is the best person to answer the above questions. Bill (Gray), Can you weigh in here? Dave Bill Regards, Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] Keep domain devices list sorted
From: Zeeshan Ali (Khattak) zeesha...@gnome.org While we don't guarantee the order of devices in the list returned from gvir_domain_get_devices(), its not a bad idea to keep them sorted the same way we get them from configuration (XML). --- libvirt-gobject/libvirt-gobject-domain.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 7b2c7ad..0bafa7e 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -909,5 +909,5 @@ GList *gvir_domain_get_devices(GVirDomain *domain, } g_list_free (config_devices); -return ret; +return g_list_reverse (ret); } -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Keep domain devices list sorted
On 03/06/2012 03:27 PM, Zeeshan Ali (Khattak) wrote: From: Zeeshan Ali (Khattak) zeesha...@gnome.org While we don't guarantee the order of devices in the list returned from gvir_domain_get_devices(), its not a bad idea to keep them sorted the same way we get them from configuration (XML). Actually, if I understand things right, preserving order _is_ important to guarantee. For example, with older XML that lacked per-device boot order='n'/, libvirt would determine which order devices are presented to guest BIOS boot order based on their position within XML. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Keep domain devices list sorted
On Wed, Mar 7, 2012 at 1:03 AM, Eric Blake ebl...@redhat.com wrote: On 03/06/2012 03:27 PM, Zeeshan Ali (Khattak) wrote: From: Zeeshan Ali (Khattak) zeesha...@gnome.org While we don't guarantee the order of devices in the list returned from gvir_domain_get_devices(), its not a bad idea to keep them sorted the same way we get them from configuration (XML). Actually, if I understand things right, preserving order _is_ important to guarantee. For example, with older XML that lacked per-device boot order='n'/, libvirt would determine which order devices are presented to guest BIOS boot order based on their position within XML. Well, I agree. You only need to convince Christophe on this. :) -- Regards, Zeeshan Ali (Khattak) FSF member#5124 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3 V7] qemu driver for virDomainGetCPUstats using cpuacct cgroup.
On 03/01/2012 07:54 PM, Lai Jiangshan wrote: From: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com * Now, only cpu_time is supported. * cpuacct cgroup is used for providing percpu cputime information. * include/libvirt/libvirt.h.in - defines VIR_DOMAIN_CPU_STATS_CPUTIME Stale commit message; this change was committed earlier. * src/qemu/qemu.conf - take care of cpuacct cgroup. * src/qemu/qemu_conf.c - take care of cpuacct cgroup. * src/qemu/qemu_driver.c - added an interface * src/util/cgroup.c/h- added interface for getting percpu cputime Signed-off-by: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- src/qemu/qemu.conf |3 +- src/qemu/qemu_conf.c |3 +- src/qemu/qemu_driver.c | 146 src/util/cgroup.c |6 ++ src/util/cgroup.h |1 + 5 files changed, 157 insertions(+), 2 deletions(-) +++ b/src/qemu/qemu_driver.c @@ -12087,6 +12087,151 @@ cleanup: return ret; } +/* qemuDomainGetCPUStats() with start_cpu == -1 */ +static int +qemuDomainGetTotalcpuStats(virCgroupPtr group, + virTypedParameterPtr params, + int nparams) Indentation. +static int qemuDomainGetPercpuStats(virDomainPtr domain, +virCgroupPtr group, +virTypedParameterPtr params, +unsigned int nparams, +int start_cpu, +unsigned int ncpus) +{ +const char *map = NULL; Same issue with 'const' as in 1/3. +int rv = -1; +int i, max_id; +char *pos; +char *buf = NULL; +virTypedParameterPtr ent; +int param_idx; + +/* return the number of supported params ? */ The ? makes it look like you weren't sure. +if (ncpus == 0) { /* returns max cpu ID */ +rv = max_id; +goto cleanup; +} Actually, rv must be max_id + 1 (the size of the array, not the index of the last element in the array). +if (max_id start_cpu + ncpus - 1) +max_id = start_cpu + ncpus - 1; + +for (i = 0; i = max_id; i++) { +unsigned long long cpu_time; Hmm - start_cpu and ncpus are user-supplied values; their sum could overflow, and we should not misbehave in that case. If the user passes a start_cpu of 100, it's probably better to return an error stating that start_cpu is out of range, rather than returning 1 without populating information. On the other hand, if max_id is 3, and the user passes start_cpu 3 and ncpus 2, it makes sense to return just the one in-range entity, rather than erroring out because ncpus was too large. +if (!map[i]) +continue; +if (virStrToLong_ull(pos, pos, 10, cpu_time) 0) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, +_(cpuacct parse error)); +goto cleanup; +} +if (i start_cpu) +continue; Hmm - this leaves the return struct unpopulated for offline cpus, but the RPC protocol strips out holes on the sending side, and reconstructing on the receiving side won't know where to restore holes. It is only safe to leave holes at the end of the array (if ncpus goes beyond max_id), and we must explicitly populate 0 rather than skipping offline cpus, if they are in range. I confirmed that it also means we need to tweak the RPC code to allow reconstruction with fewer elements than ncpus, in the case where ncpus is too large. But I will submit that as a separate patch. + +static int +qemuDomainGetCPUStats(virDomainPtr domain, +virTypedParameterPtr params, +unsigned int nparams, +int start_cpu, +unsigned int ncpus, +unsigned int flags) +{ + +if (nparams == 0 ncpus == 0) /* returns max cpu id */ +ret = qemuDomainGetPercpuStats(domain, group, NULL, 0, 0, 0); If start_cpu is -1, then ncpus is non-zero; therefore, this conditional could safely be deferred to be second, at which point it becomes redundant. +else if (start_cpu == -1) /* get total */ +ret = qemuDomainGetTotalcpuStats(group, params, nparams); +else +ret = qemuDomainGetPercpuStats(domain, group, params, nparams, + start_cpu, ncpus); +++ b/src/util/cgroup.c @@ -1555,6 +1555,12 @@ int virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage) cpuacct.usage, usage); } +int virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage) Missing an export for this one. ACK with this squashed in: diff --git i/src/libvirt_private.syms w/src/libvirt_private.syms index 1f58832..c44c617 100644 --- i/src/libvirt_private.syms +++ w/src/libvirt_private.syms
Re: [libvirt] [PATCH 3/3 V7] cpu-stats command shows cpu statistics information of a domain.
On 03/01/2012 07:54 PM, Lai Jiangshan wrote: From: KAMEZAWA Hiroyuki kamezawa.hir...@jp.fujitsu.com Total: cpu_time 14.312 CPU0: cpu_time 3.253 CPU1: cpu_time 1.923 CPU2: cpu_time 7.424 CPU3: cpu_time 1.712 Personally, I like totals to appear last :) Meanwhile, since the API returns nanoseconds, but we are printing in seconds, it might be nice to output a unit. Changed from V5: add --all, --start, --count option Changed from V: rebase Again, the 'changed from' lines are better after the ---. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- tools/virsh.c | 154 +++ tools/virsh.pod |8 +++ 2 files changed, 162 insertions(+), 0 deletions(-) /* + * cpu-stats command + */ +static const vshCmdInfo info_cpu_stats[] = { +{help, N_(show domain cpu statistics)}, +{desc, N_(Display statistics about the domain's CPUs, including per-CPU statistics.)}, +{NULL, NULL}, +}; + +static const vshCmdOptDef opts_cpu_stats[] = { +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, +{all, VSH_OT_BOOL, 0, N_(Show total statistics only)}, After thinking about this a bit more, total works better for the name of this option. That is, we default to per-cpu then total, --total limits us to total only, and --start or --count limits to per-cpu only. That means my squash below will be a bit hard to follow, since it does a big block of code motion; oh well. +{start, VSH_OT_INT, 0, N_(Show statistics from this CPU)}, +{count, VSH_OT_INT, 0, N_(Number of shown CPUs at most)}, +{NULL, 0, 0, NULL}, +}; + +static bool +cmdCPUStats(vshControl *ctl, const vshCmd *cmd) +{ + +/* get supported num of parameter for total statistics */ +if ((nparams = virDomainGetCPUStats(dom, NULL, 0, -1, 1, 0)) 0) +goto failed_stats; +if (VIR_ALLOC_N(params, nparams)) +goto failed_params; + +/* passing start_cpu == -1 gives us domain's total status */ +if ((nparams = virDomainGetCPUStats(dom, params, nparams, -1, 1, 0)) 0) +goto failed_stats; + +vshPrint(ctl, Total:\n); This should be marked for translation. +for (i = 0; i nparams; i++) { +vshPrint(ctl, \t%-10s , params[i].field); +if (STREQ(params[i].field, VIR_DOMAIN_CPU_STATS_CPUTIME)) { +if (params[i].type == VIR_TYPED_PARAM_ULLONG) { +vshPrint(ctl, %12.3lf\n, + params[i].value.ul / 10.0); We're losing information; both by chopping fractional digits, and also by conversion to floating point. It's better to give the user everything and let them round. +} else { +const char *s = vshGetTypedParamValue(ctl, params[i]); +vshPrint(ctl, _(%s(ABI changed? ullong is expected)\n), s); Not sure this message is worth it. +VIR_FREE(s); +} +} else { +const char *s = vshGetTypedParamValue(ctl, params[i]); Again, malloc'd result strings should generally not be marked const. +vshPrint(ctl, _(%s\n), s); This string doesn't need translation. +VIR_FREE(s); +} +} +virTypedParameterArrayClear(params, nparams); +VIR_FREE(params); + +if (!show_per_cpu) /* show all stats only */ +goto cleanup; + +do_show_per_cpu: +/* check cpu, show_count, and ignore wrong argument */ +if (cpu 0) +cpu = 0; +if (show_count 0) +show_count = INT_MAX; + +/* get max cpu id on the node */ +if ((max_id = virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0)) 0) +goto failed_stats; +/* get percpu information */ +if ((nparams = virDomainGetCPUStats(dom, NULL, 0, -1, 1, 0)) 0) This should be 0, not -1, as the total may have a different number of stats than per-cpu. It is feasible that some hypervisors might return 0 for one of the two stats (that is, provide total but not per-cpu stats); we shouldn't error out in those cases. +goto failed_stats; + +if (VIR_ALLOC_N(params, nparams * 128)) +goto failed_params; + +while (cpu = max_id) { Per 2/3, max_id should be the array size, not the last index in the array. We also want to stop iterating if show_count was specified... +int ncpus = 128; + +if (cpu + ncpus - 1 max_id) /* id starts from 0. */ +ncpus = max_id + 1 - cpu; + +if (virDomainGetCPUStats(dom, params, nparams, cpu, ncpus, 0) 0) ...and to fully test the underlying API, if the user passes show_count of 1, we want ncpus to be 1, not 128. So rather than futzing around with max_id, it's easier to base the entire loop on show_count. +goto failed_stats; + +for (i = 0; i ncpus; i++) { +if (params[i * nparams].type
Re: [libvirt] [Patch]: spice agent-mouse support [v3]
On Tue, Mar 6, 2012 at 10:08 PM, Osier Yang jy...@redhat.com wrote: On 2012年03月05日 16:17, Zhou Peng wrote: Signed-off-by: Zhou Pengzhoup...@nfs.iscas.ac.cn spice agent-mouse support Usage: graphics type='spice' mouse mode='client'|'server'/ graphics/ diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6fcca94..0adf859 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2809,6 +2809,14 @@ qemu-kvm -net nic,model=? /dev/null tocodeno/code,span class=sincesince 0.9.3/span. /p +p + It can be specified whether client or server mouse mode + to use for spice. The default is client which enables + passing mouse events via Spice agent. Not true from the codes, (no default value is set for mode). And It's qemu spice's default. That is, if mouse mode is not specified in qemu argv. Here it's equal to graphics type='spice' element without specifying mouse mode=xx/ sub-element. And IMO passing nothing is consistent and better with qemu if no mouse sub-elem in vm-xml. think above lines can be omitted. It's duplicate with below somehow. Below is enough. + The mouse mode is set by thecodemousecode/ element, + setting it'scodemodecode/ attribute to one of +codeserver/code orcodeclient/code. Better to document since which release the element is introduced. e.g. span class=since0.9.11/span +/p /dd dtcoderdp/code/dt dd diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 3908733..bb0df03 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1776,6 +1776,17 @@ empty/ /element /optional +optional +element name=mouse +attribute name=mode +choice +valueserver/value +valueclient/value +/choice +/attribute +empty/ +/element +/optional /interleave /group group diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9654f1..b99e770 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -460,6 +460,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression, on, off); +VIR_ENUM_IMPL(virDomainGraphicsSpiceMouseMode, + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST, + default, + server, + client); + VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode, VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST, default, @@ -5710,6 +5716,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, VIR_FREE(copypaste); def-data.spice.copypaste = copypasteVal; + } else if (xmlStrEqual(cur-name, BAD_CAST mouse)) { + const char *mode = virXMLPropString(cur, mode); + int modeVal; + + if (!mode) { + virDomainReportError(VIR_ERR_XML_ERROR, %s, + _(spice mouse missing mode)); + goto error; + } + + if ((modeVal = + virDomainGraphicsSpiceMouseModeTypeFromString(mode))= 0) { + virDomainReportError(VIR_ERR_INTERNAL_ERROR, s/VIR_ERR_INTERNAL_ERROR/VIR_ERR_XML_ERROR/ + _(unknown mouse mode value '%s'), mode); + VIR_FREE(mode); + goto error; + } + VIR_FREE(mode); + + def-data.spice.mousemode = modeVal; } } cur = cur-next; @@ -11401,7 +11427,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, } if (!children (def-data.spice.image || def-data.spice.jpeg || def-data.spice.zlib || def-data.spice.playback || - def-data.spice.streaming || def-data.spice.copypaste)) { + def-data.spice.streaming || def-data.spice.copypaste || + def-data.spice.mousemode)) { virBufferAddLit(buf, \n); children = 1; } @@ -11420,6 +11447,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def-data.spice.streaming) virBufferAsprintf(buf, streaming mode='%s'/\n, virDomainGraphicsSpiceStreamingModeTypeToString(def-data.spice.streaming)); + if (def-data.spice.mousemode) + virBufferAsprintf(buf, mouse mode='%s'/\n, + virDomainGraphicsSpiceMouseModeTypeToString(def-data.spice.mousemode)); if (def-data.spice.copypaste) virBufferAsprintf(buf, clipboard copypaste='%s'/\n, virDomainGraphicsSpiceClipboardCopypasteTypeToString(def-data.spice.copypaste)); diff
Re: [libvirt] [PATCH] Add migration APIs for libxl driver
Chun Yan Liu cy...@suse.com 3/6/2012 2:29 PM I didn't get a chance to test this yet, but have some initial review comments. Signed-off-by: Chunyan Liu --- src/libxl/libxl_driver.c | 617 ++ src/libxl/libxl_driver.h | 17 ++- 2 files changed, 632 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d5fa64a..4037635 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -30,6 +30,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include internal.h #include logging.h @@ -60,6 +66,13 @@ #define XEN_SCHED_CREDIT_NPARAM 2 static libxlDriverPrivatePtr libxl_driver = NULL; +static virThread migrate_receive_thread; This prevents receiving concurrent migrations. Yes. It is a problem. Defined as static is to be used in Begin3 function virThreadCreate and in Finish3() function virThreadJoin, but actually the thread will exit when receiving data completed or meets error, so virThreadJoin doesn't have much effect here. If a call of virThreadJoin is not needed, then can specify migrate_receive_thread as a local variable. About concurrent migrations, there is another problem in migration port. Every time a migration operation is issued, it will create a socket connection between source and host to transfer data. If a port specified, target side will create a socket and bind to that port, otherwise will bind to a DEFAULT_MIGRATION_PORT (current implementation). But if 1st migration occupies the DEFAULT_MIGRATION_PORT, then 2nd migration (without specifying port) will fail to bind to the DEFAULT_MIGRATION_PORT again. So, to ensure concurrent migrations, perhaps we need a group of ports for migration usage, every migration operation probes for a usable port. How do you think? Thanks, Chunyan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] docs: Fix typo
It used lt for , reported by Kyla Zhang weiz...@redhat.com -- Pushed under trivial rule. --- docs/formatdomain.html.in |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6434ae5..42f38d3 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1096,9 +1096,9 @@ lt;/diskgt; lt;disk type='block' device='lun'gt; lt;driver name='qemu' type='raw'/gt; - lt;source dev='/dev/sda'/lt; - lt;target dev='sda' bus='scsi'/lt; - lt;address type='drive' controller='0' bus='0' target='3' unit='0'/lt; + lt;source dev='/dev/sda'/gt; + lt;target dev='sda' bus='scsi'/gt; + lt;address type='drive' controller='0' bus='0' target='3' unit='0'/gt; lt;/diskgt; lt;/devicesgt; .../pre -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] All string getters should return 'const'
From: Zeeshan Ali (Khattak) zeesha...@gnome.org There is no need for all the memory (de)allocations and especially forcing the app developers to free the strings. They can always g_strdup() the returned string if they need. --- libvirt-gconfig/libvirt-gconfig-domain-disk.c | 13 ++--- libvirt-gconfig/libvirt-gconfig-domain-disk.h |8 ++-- libvirt-gconfig/libvirt-gconfig-domain-graphics.c |3 +- libvirt-gconfig/libvirt-gconfig-domain-interface.c |9 ++-- libvirt-gconfig/libvirt-gconfig-domain-interface.h |6 +- libvirt-gconfig/libvirt-gconfig-domain.c |8 ++-- libvirt-gconfig/libvirt-gconfig-domain.h |4 +- libvirt-gconfig/libvirt-gconfig-helpers-private.h | 16 +++--- libvirt-gconfig/libvirt-gconfig-helpers.c | 54 +-- libvirt-gconfig/libvirt-gconfig-object-private.h | 10 ++-- libvirt-gconfig/libvirt-gconfig-object.c | 13 ++--- libvirt-gconfig/tests/test-domain-create.c | 18 --- libvirt-gconfig/tests/test-domain-parse.c |3 +- libvirt-gobject/libvirt-gobject-domain-disk.c | 10 ++-- libvirt-gobject/libvirt-gobject-domain-interface.c |7 +-- 15 files changed, 87 insertions(+), 95 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c index afa7eda..2944739 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c @@ -76,16 +76,15 @@ gvir_config_domain_disk_new_from_tree(GVirConfigXmlDoc *doc, GVirConfigObject *object; GVirConfigDomainDisk *disk; GVirConfigDomainDiskType type; -xmlChar *type_str; +const xmlChar *type_str; type_str = gvir_config_xml_get_attribute_content(tree, type); if (type_str == NULL) return NULL; type = gvir_config_genum_get_value(GVIR_CONFIG_TYPE_DOMAIN_DISK_TYPE, - (char *)type_str, + (const char *)type_str, GVIR_CONFIG_DOMAIN_DISK_FILE); -xmlFree(type_str); if (type == -1) return NULL; @@ -236,7 +235,7 @@ gvir_config_domain_disk_get_snapshot_type(GVirConfigDomainDisk *disk) GVIR_CONFIG_DOMAIN_DISK_SNAPSHOT_NO); } -char * +const char * gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk) { const char *attribute_name; @@ -263,7 +262,7 @@ gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk) source, attribute_name); } -char * +const char * gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk) { g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL); @@ -272,7 +271,7 @@ gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk) driver, name); } -char * +const char * gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk) { g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL); @@ -307,7 +306,7 @@ gvir_config_domain_disk_get_target_bus(GVirConfigDomainDisk *disk) GVIR_CONFIG_DOMAIN_DISK_BUS_IDE); } -char * +const char * gvir_config_domain_disk_get_target_dev(GVirConfigDomainDisk *disk) { g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL); diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.h b/libvirt-gconfig/libvirt-gconfig-domain-disk.h index 4b16b80..916421d 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-disk.h +++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.h @@ -123,12 +123,12 @@ void gvir_config_domain_disk_set_target_dev(GVirConfigDomainDisk *disk, GVirConfigDomainDiskType gvir_config_domain_disk_get_disk_type(GVirConfigDomainDisk *disk); GVirConfigDomainDiskGuestDeviceType gvir_config_domain_disk_get_guest_device_type(GVirConfigDomainDisk *disk); GVirConfigDomainDiskSnapshotType gvir_config_domain_disk_get_snapshot_type(GVirConfigDomainDisk *disk); -char *gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk); +const char *gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk); GVirConfigDomainDiskCacheType gvir_config_domain_disk_get_driver_cache(GVirConfigDomainDisk *disk); -char *gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk); -char *gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk); +const char *gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk); +const char *gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk); GVirConfigDomainDiskBus gvir_config_domain_disk_get_target_bus(GVirConfigDomainDisk *disk); -char *gvir_config_domain_disk_get_target_dev(GVirConfigDomainDisk *disk); +const char *gvir_config_domain_disk_get_target_dev(GVirConfigDomainDisk *disk); void
Re: [libvirt] [PATCH] Add migration APIs for libxl driver
Chunyan Liu wrote: Chun Yan Liu cy...@suse.com 3/6/2012 2:29 PM I didn't get a chance to test this yet, but have some initial review comments. Signed-off-by: Chunyan Liu --- src/libxl/libxl_driver.c | 617 ++ src/libxl/libxl_driver.h | 17 ++- 2 files changed, 632 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d5fa64a..4037635 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -30,6 +30,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include internal.h #include logging.h @@ -60,6 +66,13 @@ #define XEN_SCHED_CREDIT_NPARAM 2 static libxlDriverPrivatePtr libxl_driver = NULL; +static virThread migrate_receive_thread; This prevents receiving concurrent migrations. Yes. It is a problem. Defined as static is to be used in Begin3 function virThreadCreate and in Finish3() function virThreadJoin, but actually the thread will exit when receiving data completed or meets error, so virThreadJoin doesn't have much effect here. If a call of virThreadJoin is not needed, then can specify migrate_receive_thread as a local variable. About concurrent migrations, there is another problem in migration port. Every time a migration operation is issued, it will create a socket connection between source and host to transfer data. If a port specified, target side will create a socket and bind to that port, otherwise will bind to a DEFAULT_MIGRATION_PORT (current implementation). But if 1st migration occupies the DEFAULT_MIGRATION_PORT, then 2nd migration (without specifying port) will fail to bind to the DEFAULT_MIGRATION_PORT again. Ah yes, I noticed that but forgot to mention it - sorry. So, to ensure concurrent migrations, perhaps we need a group of ports for migration usage, every migration operation probes for a usable port. How do you think? You can use a virBitmap to keep track of used ports. The qemu driver uses a virBitmap to keep track of used vnc ports, e.g. see qemuProcessNextFreePort() in src/qemu/qemu_process.c. Perhaps the same range of ports qemu uses for migration (i.e. when a port is not specified by the user) can be used in the libxl driver, allowing firewalls and the like to be configured similarly between the two. Thanks, Jim -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] rpc: allow truncated return for virDomainGetCPUStats
The RPC code assumed that the array returned by the driver would be fully populated; that is, ncpus on entry resulted in ncpus * return value on exit. However, while we don't support holes in the middle of ncpus, we do want to permit the case of ncpus on entry being longer than the array returned by the driver (that is, it should be safe for the caller to pass ncpus=128 on entry, and the driver will stop populating the array when it hits max_id). There are now three cases: server 0.9.10 and client 0.9.10 or newer: No impact - there were no hypervisor drivers that supported cpu stats server 0.9.11 or newer and client 0.9.10: if the client calls with ncpus beyond the max, then the rpc call will fail on the client side and disconnect the client, but the server is no worse for the wear server 0.9.11 or newer and client 0.9.11: the server can return a truncated array and the client will do just fine I reproduced the problem by using a host with 2 CPUs, and doing: virsh cpu-stats $dom --start 1 --count 2 * daemon/remote.c (remoteDispatchDomainGetCPUStats): Allow driver to omit tail of array. * src/remote/remote_driver.c (remoteDomainGetCPUStats): Accommodate driver that omits tail of array. --- daemon/remote.c| 10 -- src/remote/remote_driver.c |6 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 74a5f16..39302cc 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3574,11 +3574,17 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED, args-flags) 0) goto cleanup; -percpu_len = ret-params.params_len / args-ncpus; - success: rv = 0; ret-nparams = percpu_len; +if (args-nparams !(args-flags VIR_TYPED_PARAM_STRING_OKAY)) { +int i; + +for (i = 0; i percpu_len; i++) { +if (params[i].type == VIR_TYPED_PARAM_STRING) +ret-nparams--; +} +} cleanup: if (rv 0) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9e74cea..031167a 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2382,7 +2382,7 @@ static int remoteDomainGetCPUStats(virDomainPtr domain, /* Check the length of the returned list carefully. */ if (ret.params.params_len nparams * ncpus || (ret.params.params_len - ret.nparams * ncpus != ret.params.params_len)) { + ((ret.params.params_len % ret.nparams) || ret.nparams nparams))) { remoteError(VIR_ERR_RPC, %s, _(remoteDomainGetCPUStats: returned number of stats exceeds limit)); @@ -2399,9 +2399,11 @@ static int remoteDomainGetCPUStats(virDomainPtr domain, } /* The remote side did not send back any zero entries, so we have - * to expand things back into a possibly sparse array. + * to expand things back into a possibly sparse array, where the + * tail of the array may be omitted. */ memset(params, 0, sizeof(*params) * nparams * ncpus); +ncpus = ret.params.params_len / ret.nparams; for (cpu = 0; cpu ncpus; cpu++) { int tmp = nparams; remote_typed_param *stride = ret.params.params_val[cpu * ret.nparams]; -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3 V7] add nodeGetCPUmap() for getting available CPU IDs in a cpumap.
On 03/06/2012 05:10 AM, Richard W.M. Jones wrote: This all appears to work. I built my own libvirt with the three remaining patches and was able to read pCPU information for a running domain. The libvirt side is now pushed. Rich: The documentation in libvirt.c correctly says that calling virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0) must tell you part of the information needed to compute the size of an array to allocate; but in v7, the return was off by one too small. But it was generally masked by the v7 virsh code overallocating to a fixed 128 slots rather than paying attention to the return value. I fixed both those problems before pushing the libvirt patches, but since you tested with v7 instead of my fixed version, you may need to double check that virt-top isn't making the same mistakes, as it might be a boundary case that only strikes on machines with 128 physical CPUs. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: allow truncated return for virDomainGetCPUStats
On 03/07/2012 12:48 PM, Eric Blake wrote: The RPC code assumed that the array returned by the driver would be fully populated; that is, ncpus on entry resulted in ncpus * return value on exit. However, while we don't support holes in the middle of ncpus, we do want to permit the case of ncpus on entry being longer than the array returned by the driver (that is, it should be safe for the caller to pass ncpus=128 on entry, and the driver will stop populating the array when it hits max_id). There are now three cases: server 0.9.10 and client 0.9.10 or newer: No impact - there were no hypervisor drivers that supported cpu stats server 0.9.11 or newer and client 0.9.10: if the client calls with ncpus beyond the max, then the rpc call will fail on the client side and disconnect the client, but the server is no worse for the wear server 0.9.11 or newer and client 0.9.11: the server can return a truncated array and the client will do just fine I reproduced the problem by using a host with 2 CPUs, and doing: virsh cpu-stats $dom --start 1 --count 2 * daemon/remote.c (remoteDispatchDomainGetCPUStats): Allow driver to omit tail of array. * src/remote/remote_driver.c (remoteDomainGetCPUStats): Accommodate driver that omits tail of array. --- daemon/remote.c| 10 -- src/remote/remote_driver.c |6 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 74a5f16..39302cc 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3574,11 +3574,17 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED, args-flags) 0) goto cleanup; -percpu_len = ret-params.params_len / args-ncpus; - success: rv = 0; ret-nparams = percpu_len; +if (args-nparams !(args-flags VIR_TYPED_PARAM_STRING_OKAY)) { +int i; + +for (i = 0; i percpu_len; i++) { +if (params[i].type == VIR_TYPED_PARAM_STRING) +ret-nparams--; +} +} cleanup: if (rv 0) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9e74cea..031167a 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2382,7 +2382,7 @@ static int remoteDomainGetCPUStats(virDomainPtr domain, /* Check the length of the returned list carefully. */ if (ret.params.params_len nparams * ncpus || (ret.params.params_len - ret.nparams * ncpus != ret.params.params_len)) { + ((ret.params.params_len % ret.nparams) || ret.nparams nparams))) { remoteError(VIR_ERR_RPC, %s, _(remoteDomainGetCPUStats: returned number of stats exceeds limit)); @@ -2399,9 +2399,11 @@ static int remoteDomainGetCPUStats(virDomainPtr domain, } /* The remote side did not send back any zero entries, so we have - * to expand things back into a possibly sparse array. + * to expand things back into a possibly sparse array, where the + * tail of the array may be omitted. */ memset(params, 0, sizeof(*params) * nparams * ncpus); +ncpus = ret.params.params_len / ret.nparams; for (cpu = 0; cpu ncpus; cpu++) { int tmp = nparams; remote_typed_param *stride =ret.params.params_val[cpu * ret.nparams]; Make sense, and ACK. But do we want to add document to declare the returned array will be truncated among the API implementation. Not neccessary though. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rpc: allow truncated return for virDomainGetCPUStats
On 03/07/2012 02:46 PM, Osier Yang wrote: On 03/07/2012 12:48 PM, Eric Blake wrote: The RPC code assumed that the array returned by the driver would be fully populated; that is, ncpus on entry resulted in ncpus * return value on exit. However, while we don't support holes in the middle of ncpus, we do want to permit the case of ncpus on entry being longer than the array returned by the driver (that is, it should be safe for the caller to pass ncpus=128 on entry, and the driver will stop populating the array when it hits max_id). There are now three cases: server 0.9.10 and client 0.9.10 or newer: No impact - there were no hypervisor drivers that supported cpu stats server 0.9.11 or newer and client 0.9.10: if the client calls with ncpus beyond the max, then the rpc call will fail on the client side and disconnect the client, but the server is no worse for the wear server 0.9.11 or newer and client 0.9.11: the server can return a truncated array and the client will do just fine I reproduced the problem by using a host with 2 CPUs, and doing: virsh cpu-stats $dom --start 1 --count 2 * daemon/remote.c (remoteDispatchDomainGetCPUStats): Allow driver to omit tail of array. * src/remote/remote_driver.c (remoteDomainGetCPUStats): Accommodate driver that omits tail of array. --- daemon/remote.c | 10 -- src/remote/remote_driver.c | 6 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 74a5f16..39302cc 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3574,11 +3574,17 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED, args-flags) 0) goto cleanup; - percpu_len = ret-params.params_len / args-ncpus; - success: rv = 0; ret-nparams = percpu_len; + if (args-nparams !(args-flags VIR_TYPED_PARAM_STRING_OKAY)) { + int i; + + for (i = 0; i percpu_len; i++) { + if (params[i].type == VIR_TYPED_PARAM_STRING) + ret-nparams--; + } + } cleanup: if (rv 0) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9e74cea..031167a 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2382,7 +2382,7 @@ static int remoteDomainGetCPUStats(virDomainPtr domain, /* Check the length of the returned list carefully. */ if (ret.params.params_len nparams * ncpus || (ret.params.params_len - ret.nparams * ncpus != ret.params.params_len)) { + ((ret.params.params_len % ret.nparams) || ret.nparams nparams))) { remoteError(VIR_ERR_RPC, %s, _(remoteDomainGetCPUStats: returned number of stats exceeds limit)); @@ -2399,9 +2399,11 @@ static int remoteDomainGetCPUStats(virDomainPtr domain, } /* The remote side did not send back any zero entries, so we have - * to expand things back into a possibly sparse array. + * to expand things back into a possibly sparse array, where the + * tail of the array may be omitted. */ memset(params, 0, sizeof(*params) * nparams * ncpus); + ncpus = ret.params.params_len / ret.nparams; for (cpu = 0; cpu ncpus; cpu++) { int tmp = nparams; remote_typed_param *stride =ret.params.params_val[cpu * ret.nparams]; Make sense, and ACK. But do we want to add document to declare the returned array will be truncated among the API implementation. Not neccessary though. Perhaps something like: * whole). Otherwise, @start_cpu represents which cpu to start * with, and @ncpus represents how many consecutive processors to * query, with statistics attributable per processor (such as - * per-cpu usage). + * per-cpu usage). If @ncpus is larger than the number of host + * CPUs, the exceeded one(s) will be just ignored. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] virsh: add option aliases
On 03/03/2012 09:02 AM, Eric Blake wrote: In the past, we have created some virsh options with less-than-stellar names. For back-compat reasons, those names must continue to parse, but we don't want to document them in help output. This introduces a new option type, an alias, which points to a canonical option name later in the option list. I'm actually quite impressed that our code has already been factored to do all option parsing through common entry points, such that I got this added in relatively few lines of code! * tools/virsh.c (VSH_OT_ALIAS): New option type. (opts_echo): Hook up an alias, for easy testing. (vshCmddefOptParse, vshCmddefHelp, vshCmddefGetOption): Allow for aliases. * tests/virshtest.c (mymain): Test new feature. --- tests/virshtest.c |6 ++ tools/virsh.c | 28 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 6474c19..87b1336 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -386,6 +386,12 @@ mymain(void) DO_TEST(30, --shell a\n, echo \t '-'\-\ \t --shell \t a); +/* Tests of alias handling. */ +DO_TEST(31, hello\n, echo, --string, hello); +DO_TEST(32, hello\n, echo --string hello); +DO_TEST(33, hello\n, echo, --str, hello); +DO_TEST(34, hello\n, echo --str hello); + # undef DO_TEST VIR_FREE(custom_uri); diff --git a/tools/virsh.c b/tools/virsh.c index aef050f..77cf4ac 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -138,7 +138,8 @@ typedef enum { VSH_OT_STRING, /* optional string option */ VSH_OT_INT, /* optional or mandatory int option */ VSH_OT_DATA, /* string data (as non-option) */ -VSH_OT_ARGV /* remaining arguments */ +VSH_OT_ARGV, /* remaining arguments */ +VSH_OT_ALIAS,/* alternate spelling for a later argument */ } vshCmdOptType; /* @@ -190,7 +191,8 @@ typedef struct { const char *name; /* the name of option, or NULL for list end */ vshCmdOptType type; /* option type */ unsigned int flags; /* flags */ -const char *help; /* non-NULL help string */ +const char *help; /* non-NULL help string; or for VSH_OT_ALIAS + * the name of a later public option */ } vshCmdOptDef; /* @@ -15209,6 +15211,7 @@ static const vshCmdInfo info_echo[] = { static const vshCmdOptDef opts_echo[] = { {shell, VSH_OT_BOOL, 0, N_(escape for shell use)}, {xml, VSH_OT_BOOL, 0, N_(escape for XML use)}, +{str, VSH_OT_ALIAS, 0, string}, {string, VSH_OT_ARGV, 0, N_(arguments to echo)}, {NULL, 0, 0, NULL} }; @@ -17256,6 +17259,18 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg, return -1; /* bool options can't be mandatory */ continue; } +if (opt-type == VSH_OT_ALIAS) { +int j; +if (opt-flags || !opt-help) +return -1; /* alias options are tracked by the original name */ +for (j = i + 1; cmd-opts[j].name; j++) { +if (STREQ(opt-help, cmd-opts[j].name)) +break; +} +if (!cmd-opts[j].name) +return -1; /* alias option must map to a later option name */ +continue; +} if (opt-flags VSH_OFLAG_REQ_OPT) { if (opt-flags VSH_OFLAG_REQ) *opts_required |= 1 i; @@ -17287,6 +17302,10 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, const vshCmdOptDef *opt =cmd-opts[i]; if (STREQ(opt-name, name)) { +if (opt-type == VSH_OT_ALIAS) { +name = opt-help; +continue; +} if ((*opts_seen (1 i)) opt-type != VSH_OT_ARGV) { vshError(ctl, _(option --%s already seen), name); return NULL; @@ -17465,6 +17484,9 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) : _([%s]...); } break; +case VSH_OT_ALIAS: +/* aliases are intentionally undocumented */ +continue; default: assert(0); } @@ -17506,6 +17528,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) shortopt ? _([--%s]string) : _(%s), opt-name); break; +case VSH_OT_ALIAS: +continue; default: assert(0); } Ah, I could recall we talked about this half year before, for creating alias (--config) for the options --persistent of commands like attach-device, then I forgot it to do it. Looks good, ACK. Osier -- libvir-list mailing list
Re: [libvirt] [PATCH 2/3] virsh: use option aliases
On 03/03/2012 09:02 AM, Eric Blake wrote: Command line interfaces should use dash, not underscore, as many keyboard layouts allow that to be typed with fewer shift key presses. Also, the US spelling of --tunneled gets more google hits than the UK spelling of --tunnelled. * tools/virsh.c (opts_migrate): Allow US variant. (opts_blkdeviotune): Prefer - over _. * tools/virsh.pod (blkdeviotune): Fix spelling. --- tools/virsh.c | 49 +++-- tools/virsh.pod | 18 +- 2 files changed, 40 insertions(+), 27 deletions(-) ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2] Attach vm-id to Open vSwitch interfaces.
This patch will allow OpenFlow controllers to identify which interface belongs to a particular VM by using the Domain UUID. ovs-vsctl get Interface vnet0 external_ids {attached-mac=52:54:00:8C:55:2C, iface-id=83ce45d6-3639-096e-ab3c-21f66a05f7fa, iface-status=active, vm-id=142a90a7-0acc-ab92-511c-586f12da8851} V2 changes: Replaced vm-uuid with vm-id. There was a discussion in Open vSwitch mailinglist that we should stick with the same DB key postfixes for the sake of consistency (e.g iface-id, vm-id ...). --- src/lxc/lxc_driver.c|3 ++- src/network/bridge_driver.c |2 +- src/qemu/qemu_command.c |3 ++- src/uml/uml_conf.c |3 ++- src/util/virnetdevopenvswitch.c | 17 ++--- src/util/virnetdevopenvswitch.h |1 + src/util/virnetdevtap.c |3 ++- src/util/virnetdevtap.h |1 + 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index d9cbd9e..3a55983 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1197,7 +1197,8 @@ static int lxcSetupInterfaceBridged(virConnectPtr conn, goto cleanup; if (vport vport-virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) -ret = virNetDevOpenvswitchAddPort(brname, parentVeth, net-mac, vport); +ret = virNetDevOpenvswitchAddPort(brname, parentVeth, net-mac, + vm-uuid, vport); else ret = virNetDevBridgeAddPort(brname, parentVeth); if (ret 0) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index cf75d26..d82212f 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1766,7 +1766,7 @@ networkStartNetworkVirtual(struct network_driver *driver, } if (virNetDevTapCreateInBridgePort(network-def-bridge, macTapIfName, network-def-mac, - NULL, NULL, + NULL, NULL, NULL, VIR_NETDEV_TAP_CREATE_USE_MAC_FOR_BRIDGE) 0) { VIR_FREE(macTapIfName); goto err0; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 867c460..87eebce 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -244,7 +244,8 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR; } -err = virNetDevTapCreateInBridgePort(brname, net-ifname, net-mac, tapfd, +err = virNetDevTapCreateInBridgePort(brname, net-ifname, net-mac, + def-uuid, tapfd, virDomainNetGetActualVirtPortProfile(net), tap_create_flags); virDomainAuditNetDevice(def, net, /dev/net/tun, tapfd = 0); diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 397d332..eae67f9 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -138,7 +138,8 @@ umlConnectTapDevice(virConnectPtr conn, template_ifname = true; } -if (virNetDevTapCreateInBridgePort(bridge, net-ifname, net-mac, NULL, +if (virNetDevTapCreateInBridgePort(bridge, net-ifname, net-mac, + vm-uuid, NULL, virDomainNetGetActualVirtPortProfile(net), VIR_NETDEV_TAP_CREATE_IFUP) 0) { if (template_ifname) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index e427c94..1a61345 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -36,6 +36,7 @@ * @brname: the bridge name * @ifname: the network interface name * @macaddr: the mac address of the virtual interface + * @vmuuid: the Domain UUID that has this interface * @ovsport: the ovs specific fields * * Add an interface to the OVS bridge @@ -44,24 +45,31 @@ */ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, const unsigned char *macaddr, + const unsigned char *vmuuid, virNetDevVPortProfilePtr ovsport) { int ret = -1; virCommandPtr cmd = NULL; char macaddrstr[VIR_MAC_STRING_BUFLEN]; -char uuidstr[VIR_UUID_STRING_BUFLEN]; +char ifuuidstr[VIR_UUID_STRING_BUFLEN]; +char vmuuidstr[VIR_UUID_STRING_BUFLEN]; char *attachedmac_ex_id = NULL; char *ifaceid_ex_id = NULL; char *profile_ex_id = NULL; +char *vmid_ex_id = NULL; virMacAddrFormat(macaddr, macaddrstr); -virUUIDFormat(ovsport-u.openvswitch.interfaceID, uuidstr); +virUUIDFormat(ovsport-u.openvswitch.interfaceID, ifuuidstr); +virUUIDFormat(vmuuid, vmuuidstr); if (virAsprintf(attachedmac_ex_id, external-ids:attached-mac=\%s\, macaddrstr)
Re: [libvirt] [PATCH 3/3] virsh: add command aliases, and rename nodedev-detach
On 03/03/2012 09:02 AM, Eric Blake wrote: Just because our public API has a typo doesn't mean that virsh has to keep the typo. * tools/virsh.c (VSH_CMD_FLAG_ALIAS): New flag. (nodedevCmds): Use it. (cmdHelp): Omit alias commands. (cmdNodeDeviceDettach): Rename... (cmdNodeDeviceDetach): ...to this. * tools/virsh.pod (nodedev-detach): Document it. --- tools/virsh.c | 30 +++--- tools/virsh.pod | 10 ++ 2 files changed, 25 insertions(+), 15 deletions(-) ACK, guy who plays with hostdev passthrough with be happly with the changes. :-) Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Patch]: spice agent-mouse support [v3]
On 03/07/2012 10:02 AM, Zhou Peng wrote: On Tue, Mar 6, 2012 at 10:08 PM, Osier Yangjy...@redhat.com wrote: On 2012年03月05日 16:17, Zhou Peng wrote: Signed-off-by: Zhou Pengzhoup...@nfs.iscas.ac.cn spice agent-mouse support Usage: graphics type='spice' mouse mode='client'|'server'/ graphics/ diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6fcca94..0adf859 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2809,6 +2809,14 @@ qemu-kvm -net nic,model=? /dev/null tocodeno/code,span class=sincesince 0.9.3/span. /p +p + It can be specified whether client or server mouse mode + to use for spice. The default is client which enables + passing mouse events via Spice agent. Not true from the codes, (no default value is set for mode). And It's qemu spice's default. That is, if mouse mode is not specified in qemu argv. Here it's equal tographics type='spice' element without specifyingmouse mode=xx/ sub-element. And IMO passing nothing is consistent and better with qemu if nomouse sub-elem in vm-xml. The new introduced XML will make sense for all hypervisor drivers, (Note that libvirt is a general lib for kinds of hypervisor drivers), so you should declare it's only for qemu if really wants to ducument it. E.g. snip If no rom bar is specified, the qemu default will be used (older versions of qemu used a default of off, while newer qemus have a default of on). /snip think above lines can be omitted. It's duplicate with below somehow. Below is enough. + The mouse mode is set by thecodemousecode/element, + setting it'scodemodecode/attribute to one of +codeserver/codeorcodeclient/code. Better to document since which release the element is introduced. e.g.span class=since0.9.11/span +/p /dd dtcoderdp/code/dt dd diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 3908733..bb0df03 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1776,6 +1776,17 @@ empty/ /element /optional +optional +element name=mouse +attribute name=mode +choice +valueserver/value +valueclient/value +/choice +/attribute +empty/ +/element +/optional /interleave /group group diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9654f1..b99e770 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -460,6 +460,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression, on, off); +VIR_ENUM_IMPL(virDomainGraphicsSpiceMouseMode, + VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST, + default, + server, + client); + VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode, VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST, default, @@ -5710,6 +5716,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, VIR_FREE(copypaste); def-data.spice.copypaste = copypasteVal; +} else if (xmlStrEqual(cur-name, BAD_CAST mouse)) { +const char *mode = virXMLPropString(cur, mode); +int modeVal; + +if (!mode) { +virDomainReportError(VIR_ERR_XML_ERROR, %s, + _(spice mouse missing mode)); +goto error; +} + +if ((modeVal = + virDomainGraphicsSpiceMouseModeTypeFromString(mode))= 0) { +virDomainReportError(VIR_ERR_INTERNAL_ERROR, s/VIR_ERR_INTERNAL_ERROR/VIR_ERR_XML_ERROR/ + _(unknown mouse mode value '%s'), mode); +VIR_FREE(mode); +goto error; +} +VIR_FREE(mode); + +def-data.spice.mousemode = modeVal; } } cur = cur-next; @@ -11401,7 +11427,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, } if (!children(def-data.spice.image || def-data.spice.jpeg || def-data.spice.zlib || def-data.spice.playback || - def-data.spice.streaming || def-data.spice.copypaste)) { + def-data.spice.streaming || def-data.spice.copypaste || + def-data.spice.mousemode)) { virBufferAddLit(buf, \n); children = 1; } @@ -11420,6 +11447,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def-data.spice.streaming) virBufferAsprintf(buf, streaming mode='%s'/\n, virDomainGraphicsSpiceStreamingModeTypeToString(def-data.spice.streaming)); +if
Re: [libvirt] [PATCH] rpc: Fix VPATH building issue
On 03/07/2012 04:56 AM, Eric Blake wrote: On 03/06/2012 10:07 AM, Guannan Ren wrote: The XDR routine .c file generated by rpcgen includes the corresponding Header file. however, the path in include directive of the header file is picked up based on the path of .x file. In the situation of VPATH Builds it will include full path of the header file rather than relative path. Hence, the error happens when compiling time For example: The libvirt source code resides in /home/testuser, I make dist in /tmp/buildvpath, the XDR routine .c file will include full path of the header file like: #include /home/testuser/src/rpc/virnetprotocol.h #include internal.h #includearpa/inet.h If we distribute the tarball to another machine to compile, it will report error as follows: rpc/virnetprotocol.c:7:59: fatal error: /home/testuser/src/rpc/virnetprotocol.h: No such file or directory Previously, we've fixed this in genprotocol.pl, via lines like this: s,#include .*remote/remote_protocol\.h,#include remote_protocol.h,; I'm wondering whether it is better to fix it there for all protocol files. --- src/Makefile.am | 14 ++ 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index e57eca2..6c9f598 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -662,12 +662,18 @@ $(srcdir)/remote/remote_driver.c: $(REMOTE_DRIVER_GENERATED) endif WITH_REMOTE %protocol.c: %protocol.x %protocol.h $(srcdir)/rpc/genprotocol.pl - $(AM_V_GEN)perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -c \ - $ $@ + $(AM_V_GEN)protocolx='$'; \ + protocolc='$@'; \ + cd $(srcdir); \ + perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -c \ + $${protocolx/'$(srcdir)/'/''} $${protocolc/'$(srcdir)/'/''} Alas, ${foo/pat/sub} is not POSIX, so we cannot use it (if /bin/sh is dash, as is the case on Debian, then this is broken). But no fear, we _do_ require GNU make, so we can use $(patsubst pat,subst,foo) instead of $${foo/pat/sub}, if we still like the approach of changing Makefile.am rather than fixing genprotocol.pl. Get it, thanks. So, given that background, what do you think of this alternative patch? From 0ec1071294c3b02c6c77df4c61cb6f039bba Mon Sep 17 00:00:00 2001 From: Eric Blakeebl...@redhat.com Date: Tue, 6 Mar 2012 13:49:53 -0700 Subject: [PATCH] rpc: generalize solution for VPATH builds Commit 5d4b0c4c80 tried to fix certain classes of VPATH builds, but was too limited. In particular, Guannan Ren reported: For example: The libvirt source code resides in /home/testuser, I make dist in /tmp/buildvpath, the XDR routine .c file will include full path of the header file like: #include /home/testuser/src/rpc/virnetprotocol.h #include internal.h #includearpa/inet.h If we distribute the tarball to another machine to compile, it will report error as follows: rpc/virnetprotocol.c:7:59: fatal error: /home/testuser/src/rpc/virnetprotocol.h: No such file or directory * src/rpc/genprotocol.pl: Fix more include lines. --- src/rpc/genprotocol.pl |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpc/genprotocol.pl b/src/rpc/genprotocol.pl index 4838325..f8e68f5 100755 --- a/src/rpc/genprotocol.pl +++ b/src/rpc/genprotocol.pl @@ -8,7 +8,7 @@ # actually fixes for 64 bit, so this file is necessary. Arguably # so is the type-punning fix. # -# Copyright (C) 2007, 2011 Red Hat, Inc. +# Copyright (C) 2007, 2011-2012 Red Hat, Inc. # # See COPYING for the license of this software. # @@ -53,13 +53,15 @@ while (RPCGEN) { s/\t//g; +# Fix VPATH builds +s,#include .*/([^/]+)protocol\.h,#include ${1}protocol.h,; + # Portability for Solaris RPC s/u_quad_t/uint64_t/g; s/quad_t/int64_t/g; s/xdr_u_quad_t/xdr_uint64_t/g; s/xdr_quad_t/xdr_int64_t/g; s/(?!IXDR_GET_INT32 )IXDR_GET_LONG/IXDR_GET_INT32/g; -s,#include .*remote/remote_protocol\.h,#include remote_protocol.h,; if (m/^}/) { $in_function = 0; It works great, so ACK here. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list