[libvirt] [PATCH] network utilities: Add functions for address-text and get/set port number
--- src/libvirt_private.syms |3 ++ src/util/network.c | 88 +- src/util/network.h |6 +++ 3 files changed, 96 insertions(+), 1 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8525dbd..15d75fd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -289,10 +289,13 @@ virFree; virSocketAddrInNetwork; virSocketAddrIsNetmask; virSocketCheckNetmask; +virSocketFormatAddr; +virSocketGetPort; virSocketGetRange; virSocketParseAddr; virSocketParseIpv4Addr; virSocketParseIpv6Addr; +virSocketSetPort; # network_conf.h diff --git a/src/util/network.c b/src/util/network.c index abd866c..094130f 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -9,6 +9,7 @@ */ #include config.h +#include arpa/inet.h #include memory.h #include network.h @@ -64,7 +65,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) { * Mostly a wrapper for getaddrinfo() extracting the address storage * from the numeric string like 1.2.3.4 or 2001:db8:85a3:0:0:8a2e:370:7334 * - * Returns the lenght of the network address or -1 in case of error. + * Returns the length of the network address or -1 in case of error. */ int virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) { @@ -116,6 +117,91 @@ virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr) { return(virSocketParseAddr(val, addr, AF_INET6)); } +/* + * virSocketFormatAddr: + * @addr: an initialised virSocketAddrPtr + * + * Returns a string representation of the given address + * Returns NULL on any error + * Caller must free the returned string + */ +char * +virSocketFormatAddr(virSocketAddrPtr addr) { +char *out; +size_t outlen; +void *inaddr; + +if (addr-stor.ss_family == AF_INET) { +outlen = INET_ADDRSTRLEN; +inaddr = addr-inet4.sin_addr; +} + +else if (addr-stor.ss_family == AF_INET6) { +outlen = INET6_ADDRSTRLEN; +inaddr = addr-inet6.sin6_addr; +} + +else { +return NULL; +} + +if (VIR_ALLOC_N(out, outlen) 0) +return NULL; + +if (inet_ntop(addr-stor.ss_family, inaddr, out, outlen) == NULL) { +VIR_FREE(out); +return NULL; +} + +return out; +} + +/* + * virSocketSetPort: + * @addr: an initialised virSocketAddrPtr + * @port: the port number to set + * + * Set the transport layer port of the given virtSocketAddr + * + * Returns 0 on success, -1 on failure + */ +int +virSocketSetPort(virSocketAddrPtr addr, in_port_t port) { +if(addr-stor.ss_family == AF_INET) { +addr-inet4.sin_port = port; +} + +else if(addr-stor.ss_family == AF_INET6) { +addr-inet6.sin6_port = port; +} + +else { +return -1; +} + +return 0; +} + +/* + * virSocketGetPort: + * @addr: an initialised virSocketAddrPtr + * + * Returns the transport layer port of the given virtSocketAddr + * Returns 0 if @addr is invalid + */ +in_port_t +virSocketGetPort(virSocketAddrPtr addr) { +if(addr-stor.ss_family == AF_INET) { +return addr-inet4.sin_port; +} + +else if(addr-stor.ss_family == AF_INET6) { +return addr-inet6.sin6_port; +} + +return 0; +} + /** * virSocketAddrIsNetmask: * @netmask: the netmask address diff --git a/src/util/network.h b/src/util/network.h index e590747..7618547 100644 --- a/src/util/network.h +++ b/src/util/network.h @@ -34,6 +34,12 @@ int virSocketParseIpv4Addr(const char *val, int virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr); +char * virSocketFormatAddr(virSocketAddrPtr addr); + +int virSocketSetPort(virSocketAddrPtr addr, in_port_t port); + +in_port_t virSocketGetPort(virSocketAddrPtr addr); + int virSocketAddrInNetwork(virSocketAddrPtr addr1, virSocketAddrPtr addr2, virSocketAddrPtr netmask); -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] network utilities: Add functions for address-text and get/set port number
On Mon, Nov 02, 2009 at 10:57:11AM +, Matthew Booth wrote: --- src/libvirt_private.syms |3 ++ src/util/network.c | 88 +- src/util/network.h |6 +++ 3 files changed, 96 insertions(+), 1 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8525dbd..15d75fd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -289,10 +289,13 @@ virFree; virSocketAddrInNetwork; virSocketAddrIsNetmask; virSocketCheckNetmask; +virSocketFormatAddr; +virSocketGetPort; virSocketGetRange; virSocketParseAddr; virSocketParseIpv4Addr; virSocketParseIpv6Addr; +virSocketSetPort; # network_conf.h diff --git a/src/util/network.c b/src/util/network.c index abd866c..094130f 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -9,6 +9,7 @@ */ #include config.h +#include arpa/inet.h #include memory.h #include network.h @@ -64,7 +65,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) { * Mostly a wrapper for getaddrinfo() extracting the address storage * from the numeric string like 1.2.3.4 or 2001:db8:85a3:0:0:8a2e:370:7334 * - * Returns the lenght of the network address or -1 in case of error. + * Returns the length of the network address or -1 in case of error. */ int virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) { @@ -116,6 +117,91 @@ virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr) { return(virSocketParseAddr(val, addr, AF_INET6)); } +/* + * virSocketFormatAddr: + * @addr: an initialised virSocketAddrPtr + * + * Returns a string representation of the given address + * Returns NULL on any error + * Caller must free the returned string + */ +char * +virSocketFormatAddr(virSocketAddrPtr addr) { +char *out; +size_t outlen; +void *inaddr; + +if (addr-stor.ss_family == AF_INET) { +outlen = INET_ADDRSTRLEN; +inaddr = addr-inet4.sin_addr; +} + +else if (addr-stor.ss_family == AF_INET6) { +outlen = INET6_ADDRSTRLEN; +inaddr = addr-inet6.sin6_addr; +} + +else { +return NULL; +} + +if (VIR_ALLOC_N(out, outlen) 0) +return NULL; + +if (inet_ntop(addr-stor.ss_family, inaddr, out, outlen) == NULL) { +VIR_FREE(out); +return NULL; +} + +return out; +} + +/* + * virSocketSetPort: + * @addr: an initialised virSocketAddrPtr + * @port: the port number to set + * + * Set the transport layer port of the given virtSocketAddr + * + * Returns 0 on success, -1 on failure + */ +int +virSocketSetPort(virSocketAddrPtr addr, in_port_t port) { +if(addr-stor.ss_family == AF_INET) { +addr-inet4.sin_port = port; +} + +else if(addr-stor.ss_family == AF_INET6) { +addr-inet6.sin6_port = port; +} + +else { +return -1; +} + +return 0; +} + +/* + * virSocketGetPort: + * @addr: an initialised virSocketAddrPtr + * + * Returns the transport layer port of the given virtSocketAddr + * Returns 0 if @addr is invalid + */ +in_port_t +virSocketGetPort(virSocketAddrPtr addr) { +if(addr-stor.ss_family == AF_INET) { +return addr-inet4.sin_port; +} + +else if(addr-stor.ss_family == AF_INET6) { +return addr-inet6.sin6_port; +} + +return 0; +} + /** * virSocketAddrIsNetmask: * @netmask: the netmask address diff --git a/src/util/network.h b/src/util/network.h index e590747..7618547 100644 --- a/src/util/network.h +++ b/src/util/network.h @@ -34,6 +34,12 @@ int virSocketParseIpv4Addr(const char *val, int virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr); +char * virSocketFormatAddr(virSocketAddrPtr addr); + +int virSocketSetPort(virSocketAddrPtr addr, in_port_t port); + +in_port_t virSocketGetPort(virSocketAddrPtr addr); + int virSocketAddrInNetwork(virSocketAddrPtr addr1, virSocketAddrPtr addr2, virSocketAddrPtr netmask); Looks fine to me except for the following: - I'm a bit concerned by in_port_t portability, I would prefer to just use int there - using int would allow to keep the usual convention of -1 as the error return value in virSocketGetPort, allowing to distinguish 0 as not set and -1 as input parameter error - even if they are internal calls I would check the passed pointers against NULL in all the new routines. but looks like a good set to me :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com
[libvirt] [PATCH] network utilities: Add functions for address-text and get/set port number
--- src/libvirt_private.syms |3 + src/util/network.c | 97 +- src/util/network.h |6 +++ 3 files changed, 105 insertions(+), 1 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8525dbd..15d75fd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -289,10 +289,13 @@ virFree; virSocketAddrInNetwork; virSocketAddrIsNetmask; virSocketCheckNetmask; +virSocketFormatAddr; +virSocketGetPort; virSocketGetRange; virSocketParseAddr; virSocketParseIpv4Addr; virSocketParseIpv6Addr; +virSocketSetPort; # network_conf.h diff --git a/src/util/network.c b/src/util/network.c index abd866c..674e768 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -9,6 +9,7 @@ */ #include config.h +#include arpa/inet.h #include memory.h #include network.h @@ -64,7 +65,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) { * Mostly a wrapper for getaddrinfo() extracting the address storage * from the numeric string like 1.2.3.4 or 2001:db8:85a3:0:0:8a2e:370:7334 * - * Returns the lenght of the network address or -1 in case of error. + * Returns the length of the network address or -1 in case of error. */ int virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) { @@ -116,6 +117,100 @@ virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr) { return(virSocketParseAddr(val, addr, AF_INET6)); } +/* + * virSocketFormatAddr: + * @addr: an initialised virSocketAddrPtr + * + * Returns a string representation of the given address + * Returns NULL on any error + * Caller must free the returned string + */ +char * +virSocketFormatAddr(virSocketAddrPtr addr) { +char *out; +size_t outlen; +void *inaddr; + +if (addr == NULL) +return NULL; + +if (addr-stor.ss_family == AF_INET) { +outlen = INET_ADDRSTRLEN; +inaddr = addr-inet4.sin_addr; +} + +else if (addr-stor.ss_family == AF_INET6) { +outlen = INET6_ADDRSTRLEN; +inaddr = addr-inet6.sin6_addr; +} + +else { +return NULL; +} + +if (VIR_ALLOC_N(out, outlen) 0) +return NULL; + +if (inet_ntop(addr-stor.ss_family, inaddr, out, outlen) == NULL) { +VIR_FREE(out); +return NULL; +} + +return out; +} + +/* + * virSocketSetPort: + * @addr: an initialised virSocketAddrPtr + * @port: the port number to set + * + * Set the transport layer port of the given virtSocketAddr + * + * Returns 0 on success, -1 on failure + */ +int +virSocketSetPort(virSocketAddrPtr addr, int port) { +if (addr == NULL) +return -1; + +if(addr-stor.ss_family == AF_INET) { +addr-inet4.sin_port = port; +} + +else if(addr-stor.ss_family == AF_INET6) { +addr-inet6.sin6_port = port; +} + +else { +return -1; +} + +return 0; +} + +/* + * virSocketGetPort: + * @addr: an initialised virSocketAddrPtr + * + * Returns the transport layer port of the given virtSocketAddr + * Returns -1 if @addr is invalid + */ +int +virSocketGetPort(virSocketAddrPtr addr) { +if (addr == NULL) +return -1; + +if(addr-stor.ss_family == AF_INET) { +return addr-inet4.sin_port; +} + +else if(addr-stor.ss_family == AF_INET6) { +return addr-inet6.sin6_port; +} + +return -1; +} + /** * virSocketAddrIsNetmask: * @netmask: the netmask address diff --git a/src/util/network.h b/src/util/network.h index e590747..3762ef2 100644 --- a/src/util/network.h +++ b/src/util/network.h @@ -34,6 +34,12 @@ int virSocketParseIpv4Addr(const char *val, int virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr); +char * virSocketFormatAddr(virSocketAddrPtr addr); + +int virSocketSetPort(virSocketAddrPtr addr, int port); + +int virSocketGetPort(virSocketAddrPtr addr); + int virSocketAddrInNetwork(virSocketAddrPtr addr1, virSocketAddrPtr addr2, virSocketAddrPtr netmask); -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Add support for qemu's guestfwd
This series adds support for a vmchannel using qemu's guestfwd. I'll be following up with support for virtio-serial and RHEL5's vmchannel. A vmchannel is specified as: vmchannel type='pipe' source path='/tmp/vmchannel'/ target type='guestfwd' address='10.0.2.1' port='4600'/ /vmchannel There are a couple of minor complications. Firstly, the existing chrdev structure assumes that all front-ends take only a port. There's a bit of code churn adding a second union to this struct to allow for different data for different backends. Secondly, it turns out that the existing syntax for character devices doesn't really work for guestfwd. Specifically it won't allow common options to be added. This is fixed in qemu git with the new -chardev syntax. Consequently, this patch only adds support for guestfwd using -chardev. We add detection for -chardev, and a new internal utility function to output -chardev command lines for all existing character device backends. Matt -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/4] character device: Allow character devices to have different target types
Currently a character device's target (it's interface in the guest) has only a single property: port. This patch is in preparation for adding targets which require other properties. Target properties are moved into a union in virDomainChrDef, and a targetType field is added to identify which union member should be used. All current code which touches a virDomainChrDef is updated both to use the new union field, and to populate targetType if necessary. --- src/conf/domain_conf.c | 66 +- src/conf/domain_conf.h | 18 +++- src/esx/esx_vmx.c | 56 +-- src/qemu/qemu_conf.c|6 +++- src/qemu/qemu_driver.c |2 + src/uml/uml_conf.c | 12 src/uml/uml_driver.c|2 +- src/vbox/vbox_tmpl.c| 22 src/xen/xend_internal.c |3 ++ src/xen/xm_internal.c |3 ++ 10 files changed, 129 insertions(+), 61 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index de07e13..0e49482 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -127,6 +127,13 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, bridge, internal) +VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST, + null, + monitor, + parallel, + serial, + console) + VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST, null, vc, @@ -1305,6 +1312,7 @@ virDomainChrDefParseXML(virConnectPtr conn, char *path = NULL; char *mode = NULL; char *protocol = NULL; +const char *targetType = NULL; virDomainChrDefPtr def; if (VIR_ALLOC(def) 0) { @@ -1318,6 +1326,21 @@ virDomainChrDefParseXML(virConnectPtr conn, else if ((def-type = virDomainChrTypeFromString(type)) 0) def-type = VIR_DOMAIN_CHR_TYPE_NULL; +targetType = (const char *) node-name; +if (targetType == NULL) { +/* Shouldn't be possible */ +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + node-name is NULL at %s:%i, + __FILE__, __LINE__); +return NULL; +} +if ((def-targetType = virDomainChrTargetTypeFromString(targetType)) 0) { +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _(unknown target type for character device: %s), + targetType); +def-targetType = VIR_DOMAIN_CHR_TARGET_TYPE_NULL; +} + cur = node-children; while (cur != NULL) { if (cur-type == XML_ELEMENT_NODE) { @@ -2911,7 +2934,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (!chr) goto error; -chr-dstPort = i; +chr-target.port = i; def-parallels[def-nparallels++] = chr; } VIR_FREE(nodes); @@ -2931,7 +2954,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (!chr) goto error; -chr-dstPort = i; +chr-target.port = i; def-serials[def-nserials++] = chr; } VIR_FREE(nodes); @@ -2943,7 +2966,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (!chr) goto error; -chr-dstPort = 0; +chr-target.port = 0; /* * For HVM console actually created a serial device * while for non-HVM it was a parvirt console @@ -3945,10 +3968,12 @@ static int virDomainChrDefFormat(virConnectPtr conn, virBufferPtr buf, virDomainChrDefPtr def, - const char *name, int flags) { const char *type = virDomainChrTypeToString(def-type); +const char *targetName = virDomainChrTargetTypeToString(def-targetType); + +const char *elementName = targetName; /* Currently always the same */ if (!type) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, @@ -3958,8 +3983,8 @@ virDomainChrDefFormat(virConnectPtr conn, /* Compat with legacy console tty='/dev/pts/5'/ syntax */ virBufferVSprintf(buf, %s type='%s', - name, type); -if (STREQ(name, console) + elementName, type); +if (def-targetType == VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE def-type == VIR_DOMAIN_CHR_TYPE_PTY !(flags VIR_DOMAIN_XML_INACTIVE) def-data.file.path) { @@ -4034,11 +4059,23 @@ virDomainChrDefFormat(virConnectPtr conn, break; } -virBufferVSprintf(buf, target port='%d'/\n, - def-dstPort); +switch (def-targetType) { +case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL: +case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL: +case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE: +virBufferVSprintf(buf, target port='%d'/\n, + def-target.port);
[libvirt] [PATCH 2/4] Detect availability of QEMU -chardev command line option
--- src/qemu/qemu_conf.c |2 ++ src/qemu/qemu_conf.h |1 + 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 767965c..c4690b2 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -875,6 +875,8 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_PCIDEVICE; if (strstr(help, -mem-path)) flags |= QEMUD_CMD_FLAG_MEM_PATH; +if (strstr(help, -chardev)) +flags |= QEMUD_CMD_FLAG_CHARDEV; if (version = 9000) flags |= QEMUD_CMD_FLAG_VNC_COLON; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index f9a970f..4aa764b 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -71,6 +71,7 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_DRIVE_SERIAL = (1 19), /* -driver serial= available */ QEMUD_CMD_FLAG_XEN_DOMID = (1 20), /* -xen-domid (new style xen integration) */ QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX = (1 21), /* Does qemu support unix domain sockets for migration? */ +QEMUD_CMD_FLAG_CHARDEV = (1 22), /* Is the new -chardev arg available */ }; /* Main driver state */ -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/4] chardev: Add function to output -chardev options
Note that, on its own, this patch will generate a warning about an unused static function. --- src/qemu/qemu_conf.c | 87 ++ 1 files changed, 87 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c4690b2..3f0fbc1 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1386,6 +1386,93 @@ qemuBuildHostNetStr(virConnectPtr conn, return 0; } +/* This function outputs a -chardev command line option which describes only the + * host side of the character device */ +static int qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev, + const char *const id, + char *buf, + int buflen) +{ +switch(dev-type) { +case VIR_DOMAIN_CHR_TYPE_NULL: +if (snprintf(buf, buflen, null,id=%s, id) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_VC: +if (snprintf(buf, buflen, vc,id=%s, id) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_PTY: +if (snprintf(buf, buflen, pty,id=%s, id) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_DEV: +if (snprintf(buf, buflen, tty,id=%s,path=%s, + id, dev-data.file.path) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_FILE: +if (snprintf(buf, buflen, file,id=%s,path=%s, + id, dev-data.file.path) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_PIPE: +if (snprintf(buf, buflen, pipe,id=%s,path=%s, + id, dev-data.file.path) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_STDIO: +if (snprintf(buf, buflen, stdio,id=%s, id) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_UDP: +if (snprintf(buf, buflen, +udp,id=%s,host=%s,port=%s,localaddr=%s,localport=%s, + id, + dev-data.udp.connectHost, + dev-data.udp.connectService, + dev-data.udp.bindHost, + dev-data.udp.bindService) = buflen) +return -1; +break; + +case VIR_DOMAIN_CHR_TYPE_TCP: +{ +bool telnet = +dev-data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; + +if (snprintf(buf, buflen, + socket,id=%s,host=%s,port=%s%s%s, + id, + dev-data.tcp.host, + dev-data.tcp.service, + telnet ? ,telnet : , + dev-data.tcp.listen ? ,server,nowait : ) = buflen) +return -1; +break; +} + +case VIR_DOMAIN_CHR_TYPE_UNIX: +if (snprintf(buf, buflen, + socket,id=%s,path=%s%s, + id, + dev-data.nix.path, + dev-data.nix.listen ? ,server,nowait : ) = buflen) +return -1; +break; +} + +return 0; +} + +/* This function outputs an all-in-one character device command line option */ static int qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev, char *buf, int buflen) -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/4] Add support for qemu's guestfwd
This patch allows the following to be specified in a qemu domain: vmchannel type='pipe' source path='/tmp/vmchannel'/ target type='guestfwd' address='10.0.2.1' port='4600'/ /vmchannel This will output the following on the qemu command line: -chardev pipe,id=vmchannel0,path=/tmp/vmchannel \ -net user,guestfwd=tcp:10.0.2.1:4600-chardev:vmchannel0 --- docs/schemas/domain.rng| 92 proxy/Makefile.am |1 + src/conf/domain_conf.c | 157 +++- src/conf/domain_conf.h |6 + src/qemu/qemu_conf.c | 55 +++ .../qemuxml2argv-vmchannel-guestfwd.args |1 + .../qemuxml2argv-vmchannel-guestfwd.xml| 26 tests/qemuxml2argvtest.c |4 +- tests/qemuxml2xmltest.c|1 + 9 files changed, 305 insertions(+), 38 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vmchannel-guestfwd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-vmchannel-guestfwd.xml diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index 0a6ab61..54bbdd8 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -930,6 +930,19 @@ definition doesn't fully specify the constraints on this node. -- define name=qemucdev +ref name=qemucdevSrcType/ +interleave + ref name=qemucdevSrcDef/ + optional +element name=target + optional +attribute name=port/ + /optional +/element + /optional +/interleave + /define + define name=qemucdevSrcType attribute name=type choice valuedev/value @@ -944,43 +957,36 @@ valuepty/value /choice /attribute -interleave - optional -oneOrMore - element name=source -optional - attribute name=mode/ -/optional -optional - attribute name=path/ -/optional -optional - attribute name=host/ -/optional -optional - attribute name=service/ -/optional -optional - attribute name=wiremode/ -/optional - /element -/oneOrMore - /optional - optional -element name=protocol + /define + define name=qemucdevSrcDef +optional + oneOrMore +element name=source optional -attribute name=type/ +attribute name=mode/ /optional -/element - /optional - optional -element name=target optional -attribute name=port/ +attribute name=path/ + /optional + optional +attribute name=host/ + /optional + optional +attribute name=service/ + /optional + optional +attribute name=wiremode/ /optional /element - /optional -/interleave + /oneOrMore +/optional +optional + element name=protocol +optional + attribute name=type/ +/optional + /element +/optional /define !-- The description for a console @@ -1044,6 +1050,27 @@ ref name=qemucdev/ /element /define + define name=vmchannel +element name=vmchannel + ref name=qemucdevSrcType/ + interleave +ref name=qemucdevSrcDef/ +element name=target + attribute name=type +choice + valueguestfwd/value +/choice + /attribute + optional +attribute name=address/ + /optional + optional +attribute name=port/ + /optional +/element + /interleave +/element + /define define name=input element name=input attribute name=type @@ -1158,6 +1185,7 @@ ref name=console/ ref name=parallel/ ref name=serial/ +ref name=vmchannel/ /choice /zeroOrMore optional diff --git a/proxy/Makefile.am b/proxy/Makefile.am index 3e0050b..42f6a81 100644 --- a/proxy/Makefile.am +++ b/proxy/Makefile.am @@ -17,6 +17,7 @@ libvirt_proxy_SOURCES = libvirt_proxy.c \ @top_srcdir@/src/util/buf.c \ @top_srcdir@/src/util/logging.c \ @top_srcdir@/src/util/memory.c \ +@top_srcdir@/src/util/network.c \ @top_srcdir@/src/util/threads.c \ @top_srcdir@/src/util/util.c \ @top_srcdir@/src/util/uuid.c \ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0e49482..7708a75 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -40,6 +40,7 @@ #include buf.h #include c-ctype.h #include logging.h +#include network.h
[libvirt] [REPOST] Fix --with-init-script configure option
Looks like this one might have dropped off the radar. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Fix --with-init-script configure option
The --with-init-script configure option was broken, and always defaulted based on the existence of /etc/redhat-release. This was a systematic typo based on mixed use of init-script and init-scripts. --- configure.in | 14 +++--- daemon/Makefile.am |4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/configure.in b/configure.in index 04f6dfe..5987211 100644 --- a/configure.in +++ b/configure.in @@ -243,17 +243,17 @@ dnl init script flavor dnl AC_MSG_CHECKING([for init script flavor]) AC_ARG_WITH([init-script], -[AC_HELP_STRING([--with-init-scripts=[redhat|auto|none]], -[Style of init scripts to install (defaults to auto)])]) -if test x$with_init_scripts = x -o x$with_init_scripts = xauto; then +[AC_HELP_STRING([--with-init-script=[redhat|auto|none]], +[Style of init script to install (defaults to auto)])]) +if test x$with_init_script = x -o x$with_init_script = xauto; then if test -f /etc/redhat-release ; then -with_init_scripts=redhat +with_init_script=redhat else -with_init_scripts=none +with_init_script=none fi fi -AM_CONDITIONAL([LIBVIRT_INIT_SCRIPTS_RED_HAT], test x$with_init_scripts = xredhat) -AC_MSG_RESULT($with_init_scripts) +AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test x$with_init_script = xredhat) +AC_MSG_RESULT($with_init_script) dnl RHEL-5 has a peculiar version of Xen, which requires some special casing AC_ARG_WITH([rhel5-api], diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 84aab04..ab3f238 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -188,7 +188,7 @@ install-logrotate: libvirtd.logrotate mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/ $(INSTALL_DATA) $ $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd -if LIBVIRT_INIT_SCRIPTS_RED_HAT +if LIBVIRT_INIT_SCRIPT_RED_HAT install-init: libvirtd.init mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d $(INSTALL_SCRIPT) libvirtd.init \ @@ -222,7 +222,7 @@ install-init: uninstall-init: libvirtd.init: -endif # DBUS_INIT_SCRIPTS_RED_HAT +endif # LIBVIRT_INIT_SCRIPT_RED_HAT # This must be added last, since functions it provides/replaces # are used by nearly every other library. -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Fix virInterfaceIpDefPtr leak during virInterfaceIpDefFree().
This is the only update to the patchset already sent. All other problems were either in netcf code, or will be cleaned up later. A patch has been sent to netcf-devel which, when applied, allows make check of libvirt plus the patch series to complete with no errors. There is still one issue, affecting bond interfaces, which is not revealed by make check. I'll describe that in a separate email. --- src/conf/interface_conf.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index fc18eba..31af957 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -58,6 +58,7 @@ void virInterfaceIpDefFree(virInterfaceIpDefPtr def) { if (def == NULL) return; VIR_FREE(def-address); +VIR_FREE(def); } static -- 1.6.5.15.gc274d -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Remaining interface state reporting issue - bond options
With the patches I sent to netcf-devel last night, along with lutter's (or DV's, take your pick ;-) netcf patch to eliminate the segfault, my patches for reporting interface info now pass make check with no errors. I believe lutter will be making a netcf release tomorrow or so, after he gets back on solid ground. There is one issue left that I'm unsure what to do about - while the xml returned from netcf for bond interfaces does list all the slave interfaces of the bond and their types (and any required info for that type), the parser for bond info in libvirt requires either an miimon or arpmode node inside the bond, eg: interface type=bond name=bond0 bond miimon freq=100 updelay=10 carrier=ioctl/ interface type=ethernet name=eth1/ interface type=ethernet name=eth0/ /bond /interface I haven't been able to find a source of this information yet and, while it may be useful, I don't see it as necessary. Once again I'm proposing that we make these optional in the XML, such that this would be acceptable: interface type=bond name=bond0 bond interface type=ethernet name=eth1/ interface type=ethernet name=eth0/ /bond /interface Once we do that, the netcf-reported state of all 4 supported interface types (ethernet, bridge, vlan, bond) will pass libvirt's parsing test. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix virInterfaceIpDefPtr leak during virInterfaceIpDefFree().
On Mon, Nov 02, 2009 at 08:34:50AM -0500, Laine Stump wrote: This is the only update to the patchset already sent. All other problems were either in netcf code, or will be cleaned up later. A patch has been sent to netcf-devel which, when applied, allows make check of libvirt plus the patch series to complete with no errors. There is still one issue, affecting bond interfaces, which is not revealed by make check. I'll describe that in a separate email. --- src/conf/interface_conf.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index fc18eba..31af957 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -58,6 +58,7 @@ void virInterfaceIpDefFree(virInterfaceIpDefPtr def) { if (def == NULL) return; VIR_FREE(def-address); +VIR_FREE(def); } ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Remaining interface state reporting issue - bond options
On Mon, Nov 02, 2009 at 08:44:26AM -0500, Laine Stump wrote: With the patches I sent to netcf-devel last night, along with lutter's (or DV's, take your pick ;-) netcf patch to eliminate the segfault, my patches for reporting interface info now pass make check with no errors. I believe lutter will be making a netcf release tomorrow or so, after he gets back on solid ground. There is one issue left that I'm unsure what to do about - while the xml returned from netcf for bond interfaces does list all the slave interfaces of the bond and their types (and any required info for that type), the parser for bond info in libvirt requires either an miimon or arpmode node inside the bond, eg: interface type=bond name=bond0 bond miimon freq=100 updelay=10 carrier=ioctl/ interface type=ethernet name=eth1/ interface type=ethernet name=eth0/ /bond /interface I haven't been able to find a source of this information yet and, while it may be useful, I don't see it as necessary. Once again I'm proposing that we make these optional in the XML, such that this would be acceptable: interface type=bond name=bond0 bond interface type=ethernet name=eth1/ interface type=ethernet name=eth0/ /bond /interface Once we do that, the netcf-reported state of all 4 supported interface types (ethernet, bridge, vlan, bond) will pass libvirt's parsing test. That sounds OK to me - the miimon vs arpmode stuff is not critical. The interface topology is the only really important thing you've got that working now. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Remaining interface state reporting issue - bond options
On 11/02/2009 09:12 AM, Daniel P. Berrange wrote: On Mon, Nov 02, 2009 at 08:44:26AM -0500, Laine Stump wrote: I haven't been able to find a source of this information yet and, while it may be useful, I don't see it as necessary. Once again I'm proposing that we make these optional in the XML, such that this would be acceptable: interface type=bond name=bond0 bond interface type=ethernet name=eth1/ interface type=ethernet name=eth0/ /bond /interface Once we do that, the netcf-reported state of all 4 supported interface types (ethernet, bridge, vlan, bond) will pass libvirt's parsing test. That sounds OK to me - the miimon vs arpmode stuff is not critical. The interface topology is the only really important thing you've got that working now. Ok. I'll try and get a patch to make them optinoal in the next few hours... -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] libvirt generates bad kvm command line
Hi folks, using this command sequence code export VIRSH_DEFAULT_CONNECT_URI=qemu:///system name=Testing kvmdir=/export/hdunkel/kvm hda=$kvmdir/$name/hda.qcow2 iso=/export/isos/debian-testing-amd64-netinst.iso mkdir -p $kvmdir/$name qemu-img create -f qcow2 $hda 32G virt-install --connect ${VIRSH_DEFAULT_CONNECT_URI} \ -n $name -r 1024 -vcpus=1 -f $hda -c $iso \ --network=bridge:br0 --vnc --accelerate -v \ --os-type=linux --os-variant=debianSqueeze /code I get the famous cdrom boot failure code 0003 error. The log file shows that libvirt generated this kvm command line: code LC_ALL=C \ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \ HOME=/root USER=root LOGNAME=root QEMU_AUDIO_DRV=none \ /usr/bin/kvm -S -M pc -m 1024 -smp 1 -name Testing \ -uuid 3a6b6b3f-84e6-6a21-a51a-2c61cf3914e2 \ -monitor unix:/var/lib/libvirt/qemu/Testing.monitor,server,nowait \ -no-reboot -boot d \ -drive file=/export/hdunkel/kvm/Testing/hda.qcow2,if=virtio,index=0 -drive file=/export/isos/debian-testing-amd64-netinst.iso,if=virtio,media=cdrom,index=1 \ -net nic,macaddr=52:54:00:3e:0b:26,vlan=0,model=virtio,name=virtio.0 \ -net tap,fd=18,vlan=0,name=tap.0 -serial pty -parallel none \ -usb -usbdevice tablet -vnc 127.0.0.1:0 -k en-us -vga cirrus /code If I try this on the command line, then there is the same 0003 error. If I omit the if=virtio for the cdrom drive, then it boots the cd without 0003. Can you reproduce this? Is this a problem with libvirt or with the kvm module? Kernel is 2.6.31.5, i.e. kvm 0.88. libvirt is 0.7.2 Any helpful comments would be highly appreciated. Harri -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Don't use private struct member names of in6_addr
On Sat, Oct 31, 2009 at 12:16:14PM +0100, Daniel Veillard wrote: On Fri, Oct 30, 2009 at 05:07:50PM +0100, Matthias Bolte wrote: __in6_u.__u6_addr16 is the private name for this struct member, s6_addr16 is the public one. Our buildserver revealed this problem, because for some reason the internal names are missing the __ prefix there. Matthias diff --git a/src/util/network.c b/src/util/network.c index abd866c..5e3cb3a 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -46,7 +46,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) { if ((addr == NULL) || (tab == NULL) || (addr-stor.ss_family != AF_INET6)) return(-1); -val = (virIPv6AddrPtr) (addr-inet6.sin6_addr.__in6_u.__u6_addr16); +val = (virIPv6AddrPtr) (addr-inet6.sin6_addr.s6_addr16); for (i = 0;i 8;i++) { (*tab)[i] = ntohs((*val)[i]); ACK ! Thanks for spotting this ! Okay, I commited it ! thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Re: [PATCH] network utilities: Add functions for address-text and get/set port number
On Mon, Nov 02, 2009 at 11:24:13AM +, Matthew Booth wrote: --- src/libvirt_private.syms |3 + src/util/network.c | 97 +- src/util/network.h |6 +++ 3 files changed, 105 insertions(+), 1 deletions(-) Heh thanks for the fast feedback, applied and pushed :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC][PATCH] LXC allow a container to have ethN named interfaces
Note that this patch is not mature yet and still proof- of-concept prototype, although it actually works. Current implementation of lxc driver creates vethN named interface(s) in the host and passes as it is to a container. The reason why it doesn't use ethN is due to the limitation that one namespace cannot have multiple iterfaces that have an identical name so that we give up creating ethN named interface in the host for the container. However, we should be able to allow the container to have ethN by changing the name after clone(CLONE_NEWNET) in controller. To this end, this patch extends --veth argument of controller to be able to have two names; one is the name of a created veth, and the other is a new name. The format is: --veth veth1,eth0 --veth veth3,eth1 ... where veth1 is old name and eth0 is new one. The implementation also allows a single name, in that case, controller does not do nothing for the interface, which is the original behavior. The numbering of the new names is simply ascending order from zero. So if there is one interface, its name will be eth0. --- src/lxc/lxc_container.c | 23 ++- src/lxc/lxc_container.h |1 + src/lxc/lxc_controller.c | 30 -- src/lxc/lxc_driver.c | 30 +- src/lxc/veth.c | 20 src/lxc/veth.h |1 + 6 files changed, 93 insertions(+), 12 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index f4381e7..f065788 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -84,6 +84,7 @@ struct __lxc_child_argv { virDomainDefPtr config; unsigned int nveths; char **veths; +char **newveths; int monitor; char *ttyPath; }; @@ -233,14 +234,23 @@ static int lxcContainerWaitForContinue(int control) * Returns 0 on success or nonzero in case of error */ static int lxcContainerEnableInterfaces(unsigned int nveths, -char **veths) +char **veths, char **newveths) { int rc = 0; unsigned int i; for (i = 0 ; i nveths ; i++) { -DEBUG(Enabling %s, veths[i]); -rc = vethInterfaceUpOrDown(veths[i], 1); +char *veth = veths[i]; +if (newveths[i] !STREQ(veths[i], newveths[i])) { +DEBUG(changing %s, veths[i]); +rc = setInterfaceName(veths[i], newveths[i]); +if (0 != rc) { +goto error_out; +} +veth = newveths[i]; +} +DEBUG(Enabling %s, veth); +rc = vethInterfaceUpOrDown(veth, 1); if (0 != rc) { goto error_out; } @@ -758,7 +768,9 @@ static int lxcContainerChild( void *data ) return -1; /* enable interfaces */ -if (lxcContainerEnableInterfaces(argv-nveths, argv-veths) 0) +if (lxcContainerEnableInterfaces(argv-nveths, + argv-veths, + argv-newveths) 0) return -1; /* drop a set of root capabilities */ @@ -786,6 +798,7 @@ static int userns_supported(void) int lxcContainerStart(virDomainDefPtr def, unsigned int nveths, char **veths, + char **newveths, int control, char *ttyPath) { @@ -793,7 +806,7 @@ int lxcContainerStart(virDomainDefPtr def, int flags; int stacksize = getpagesize() * 4; char *stack, *stacktop; -lxc_child_argv_t args = { def, nveths, veths, control, ttyPath }; +lxc_child_argv_t args = { def, nveths, veths, newveths, control, ttyPath }; /* allocate a stack for the container */ if (VIR_ALLOC_N(stack, stacksize) 0) { diff --git a/src/lxc/lxc_container.h b/src/lxc/lxc_container.h index a1dd5a1..d796380 100644 --- a/src/lxc/lxc_container.h +++ b/src/lxc/lxc_container.h @@ -49,6 +49,7 @@ int lxcContainerSendContinue(int control); int lxcContainerStart(virDomainDefPtr def, unsigned int nveths, char **veths, + char **newveths, int control, char *ttyPath); diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 545f718..75dd73a 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -493,6 +493,7 @@ static int lxcControllerRun(virDomainDefPtr def, unsigned int nveths, char **veths, + char **newveths, int monitor, int client, int appPty) @@ -603,6 +604,7 @@ lxcControllerRun(virDomainDefPtr def, if ((container = lxcContainerStart(def, nveths, veths, + newveths,
Re: [libvirt] [PATCH] Fix --with-init-script configure option
On Mon, Nov 02, 2009 at 12:05:55PM +, Matthew Booth wrote: The --with-init-script configure option was broken, and always defaulted based on the existence of /etc/redhat-release. This was a systematic typo based on mixed use of init-script and init-scripts. --- configure.in | 14 +++--- daemon/Makefile.am |4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/configure.in b/configure.in index 04f6dfe..5987211 100644 --- a/configure.in +++ b/configure.in @@ -243,17 +243,17 @@ dnl init script flavor dnl AC_MSG_CHECKING([for init script flavor]) AC_ARG_WITH([init-script], -[AC_HELP_STRING([--with-init-scripts=[redhat|auto|none]], - [Style of init scripts to install (defaults to auto)])]) -if test x$with_init_scripts = x -o x$with_init_scripts = xauto; then +[AC_HELP_STRING([--with-init-script=[redhat|auto|none]], + [Style of init script to install (defaults to auto)])]) +if test x$with_init_script = x -o x$with_init_script = xauto; then if test -f /etc/redhat-release ; then -with_init_scripts=redhat +with_init_script=redhat else -with_init_scripts=none +with_init_script=none fi fi -AM_CONDITIONAL([LIBVIRT_INIT_SCRIPTS_RED_HAT], test x$with_init_scripts = xredhat) -AC_MSG_RESULT($with_init_scripts) +AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test x$with_init_script = xredhat) +AC_MSG_RESULT($with_init_script) dnl RHEL-5 has a peculiar version of Xen, which requires some special casing AC_ARG_WITH([rhel5-api], diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 84aab04..ab3f238 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -188,7 +188,7 @@ install-logrotate: libvirtd.logrotate mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/ $(INSTALL_DATA) $ $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd -if LIBVIRT_INIT_SCRIPTS_RED_HAT +if LIBVIRT_INIT_SCRIPT_RED_HAT install-init: libvirtd.init mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d $(INSTALL_SCRIPT) libvirtd.init \ @@ -222,7 +222,7 @@ install-init: uninstall-init: libvirtd.init: -endif # DBUS_INIT_SCRIPTS_RED_HAT +endif # LIBVIRT_INIT_SCRIPT_RED_HAT # This must be added last, since functions it provides/replaces # are used by nearly every other library. ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] give up python interpreter lock before calling cb
suggested by danpb on irc --- python/libvirt-override.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 5d24fd2..53e36c0 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -2355,7 +2355,9 @@ libvirt_virEventInvokeHandleCallback(PyObject *self ATTRIBUTE_UNUSED, opaque = (void *) PyvirVoidPtr_Get(py_opaque); if(cb) +LIBVIRT_BEGIN_ALLOW_THREADS cb (watch, fd, event, opaque); +LIBVIRT_END_ALLOW_THREADS return VIR_PY_INT_SUCCESS; } @@ -2379,7 +2381,9 @@ libvirt_virEventInvokeTimeoutCallback(PyObject *self ATTRIBUTE_UNUSED, cb = (virEventTimeoutCallback) PyvirEventTimeoutCallback_Get(py_f); opaque = (void *) PyvirVoidPtr_Get(py_opaque); if(cb) +LIBVIRT_BEGIN_ALLOW_THREADS cb (timer, opaque); +LIBVIRT_END_ALLOW_THREADS return VIR_PY_INT_SUCCESS; } -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] libvirt generates bad kvm command line
On 11/02/2009 10:54 AM, Chris Lalancette wrote: Harald Dunkel wrote: If I try this on the command line, then there is the same 0003 error. If I omit the if=virtio for the cdrom drive, then it boots the cd without 0003. Yeah, the if=virtio on the cdrom line is bogus. Can you reproduce this? Is this a problem with libvirt or with the kvm module? Neither. I believe this was a bug with virt-install that has been since fixed. Cole, do you have a link to the fix? Yeah, the commit is here (the last hunk is the important one): http://hg.fedorahosted.org/hg/python-virtinst/rev/252ff7bc5ff9 Relevant fedora packages should have the fix. - Cole -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] give up python interpreter lock before calling cb
On Mon, Nov 02, 2009 at 06:09:52PM +0200, Dan Kenigsberg wrote: suggested by danpb on irc --- python/libvirt-override.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 5d24fd2..53e36c0 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -2355,7 +2355,9 @@ libvirt_virEventInvokeHandleCallback(PyObject *self ATTRIBUTE_UNUSED, opaque = (void *) PyvirVoidPtr_Get(py_opaque); if(cb) +LIBVIRT_BEGIN_ALLOW_THREADS cb (watch, fd, event, opaque); +LIBVIRT_END_ALLOW_THREADS You'll need some curly braces around that, otherwise it is doing if(cb) LIBVIRT_BEGIN_ALLOW_THREADS cb (watch, fd, event, opaque); LIBVIRT_END_ALLOW_THREADS daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] give up python interpreter lock before calling cb
On Mon, Nov 02, 2009 at 04:17:10PM +, Daniel P. Berrange wrote: On Mon, Nov 02, 2009 at 06:09:52PM +0200, Dan Kenigsberg wrote: suggested by danpb on irc --- python/libvirt-override.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 5d24fd2..53e36c0 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -2355,7 +2355,9 @@ libvirt_virEventInvokeHandleCallback(PyObject *self ATTRIBUTE_UNUSED, opaque = (void *) PyvirVoidPtr_Get(py_opaque); if(cb) +LIBVIRT_BEGIN_ALLOW_THREADS cb (watch, fd, event, opaque); +LIBVIRT_END_ALLOW_THREADS You'll need some curly braces around that, otherwise it is doing if(cb) LIBVIRT_BEGIN_ALLOW_THREADS cb (watch, fd, event, opaque); LIBVIRT_END_ALLOW_THREADS grr. bad case of python poisoning. anyway, the patch is here only for you not to forget it.. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [patch] Add openvzDomainSetMemoryInternal
On Tue, Oct 27, 2009 at 04:12:47PM +0900, Yuji NISHIDA wrote: Hi all, This patch is to set KMEMSIZE for OpenVZ. This function is used for initializing the parameter of KMEMSIZE to start container. openvzDomainSetMemory should be left for another purpose so I added new one. I think users should specify memory as kbyte ( or bigger ). That's the definition all entry points for memory use KB as the unit. so that's what you get in the driver and XML format files. --- src/openvz/openvz_driver.c | 32 1 files changed, 32 insertions(+), 0 deletions(-) Your mail agent made garbage (nearly) of the patch, in the future please provide your patches as attachement. diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index f64ad1e..5c1fefa 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -69,6 +69,7 @@ static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type); static int openvzDomainGetMaxVcpus(virDomainPtr dom); static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus); static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm, unsigned int nvcpus); +static int openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm, unsigned long memory); static void openvzDriverLock(struct openvz_driver *driver) { @@ -803,6 +804,14 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) } } +if (vm-def-memory 0) { +if (openvzDomainSetMemoryInternal(conn, vm, vm-def-memory) 0) { +openvzError(conn, VIR_ERR_INTERNAL_ERROR, + %s, _(Could not set memory size)); + goto cleanup; +} +} + dom = virGetDomain(conn, vm-def-name, vm-def-uuid); if (dom) dom-id = -1; @@ -1364,6 +1373,29 @@ static int openvzNumDefinedDomains(virConnectPtr conn) { return ninactive; } +static int openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm, + unsigned long mem) { +struct openvz_driver *driver = conn-privateData; That variable is unused. Compiling the code show the warning. How did you miss this ? +char str_mem[16]; +const char *prog[] = { VZCTL, --quiet, set, PROGRAM_SENTINAL, + --kmemsize, str_mem, --save, NULL }; + +/* memory has to be changed its format from kbyte to byte */ +snprintf( str_mem, sizeof(str_mem), %lu, mem * 1024 ); + +openvzSetProgramSentinal(prog, vm-def-name); +if (virRun(conn, prog, NULL) 0) { +openvzError(conn, VIR_ERR_INTERNAL_ERROR, + _(Could not exec %s), VZCTL); +goto cleanup; +} + +return 0; + +cleanup: +return -1; +} + static virDriver openvzDriver = { VIR_DRV_OPENVZ, OPENVZ, That said the patch looks sensible to me, I applied it by hand, cleaned up the formatting, and removed the unused variable. thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] ESX: Don't automatically follow redirects.
On Mon, Nov 02, 2009 at 05:24:38PM +0100, Matthias Bolte wrote: 2009/10/29 Matthias Bolte matthias.bo...@googlemail.com: 2009/10/28 Daniel P. Berrange berra...@redhat.com: On Wed, Oct 28, 2009 at 09:12:06PM +0100, Matthias Bolte wrote: The default transport for the VI API is HTTPS. If the server redirects from HTTPS to HTTP the driver would silently follow that redirection. The user assumes to communicate with the server over a secure transport but isn't. Good catch, this is definitely something we don't want to happen. This patch disables automatical redirection following. The driver reports an error if the server tries to redirect. Is the user likely to hit any redirects in the real world, or is this just an edge case. If they're likely to hit redirects, then we might want to allow a redirect if it points to another paths on the same server as the original URI, and is using HTTPS. Daniel As far as I can tell it's an edge case. The available transports can be configured on the ESX server. Default is HTTPS-only, but you can configure it to use HTTPS+HTTP or HTTP-only. The ESX server redirects you to the other protocol if you try to access it via a disabled one. I'm not aware of any other situation that results in a redirect. Matthias If not doubts are left then I'm going to push this 5 ESX patches. Fine by me ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix --with-init-script configure option
On Mon, Nov 02, 2009 at 12:05:55PM +, Matthew Booth wrote: The --with-init-script configure option was broken, and always defaulted based on the existence of /etc/redhat-release. This was a systematic typo based on mixed use of init-script and init-scripts. I see, nice catch ! Applied and pushed, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] cannot get virt-manager to see VM
I used qemu-img to create a raw image. I then create an xml file with no uuid but a new name and new mac address. Then I did a 'virsh define NEW.img'. When I do a 'virsh list --all' the new VM is there but shut_off. But this new machine does not appear in virt-manager. What do I need to do to get the new machine to appear in the list of machines in virt-manager? I want to start this machine using virt-manager. This is on F11 with libvirt 0.6.2. -Gerry -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2] Improve error reporting for virConnectGetHostname calls
All drivers have copy + pasted inadequate error reporting which wraps util.c:virGetHostname. Move all error reporting to this function, and improve what we report. Changes from v1: Drop the driver wrappers around virGetHostname. This means we still need to keep the new conn argument to virGetHostname, but I think it's worth it. Signed-off-by: Cole Robinson crobi...@redhat.com --- daemon/libvirtd.c |7 +++ src/lxc/lxc_driver.c| 16 +--- src/qemu/qemu_driver.c | 22 ++ src/test/test_driver.c | 16 +--- src/uml/uml_driver.c| 17 + src/util/util.c | 18 +++--- src/util/util.h |2 +- src/vbox/vbox_tmpl.c| 16 +--- src/xen/xen_driver.c| 20 +--- src/xen/xend_internal.c |6 ++ tools/virsh.c |2 +- 11 files changed, 29 insertions(+), 113 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 0615cd2..322a320 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -993,11 +993,10 @@ static int qemudNetworkInit(struct qemud_server *server) { if (!mdns_name) { char groupname[64], *localhost, *tmp; /* Extract the host part of the potentially FQDN */ -localhost = virGetHostname(); -if (localhost == NULL) { -virReportOOMError(NULL); +localhost = virGetHostname(NULL); +if (localhost == NULL) goto cleanup; -} + if ((tmp = strchr(localhost, '.'))) *tmp = '\0'; snprintf(groupname, sizeof(groupname)-1, Virtualization Host %s, localhost); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 47e59f6..05fc48d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2027,20 +2027,6 @@ cleanup: return ret; } -static char *lxcGetHostname (virConnectPtr conn) -{ -char *result; - -result = virGetHostname(); -if (result == NULL) { -virReportSystemError (conn, errno, - %s, _(failed to determine host name)); -return NULL; -} -/* Caller frees this string. */ -return result; -} - static int lxcFreezeContainer(lxc_driver_t *driver, virDomainObjPtr vm) { int timeout = 1000; /* In milliseconds */ @@ -2258,7 +2244,7 @@ static virDriver lxcDriver = { NULL, /* supports_feature */ NULL, /* type */ lxcVersion, /* version */ -lxcGetHostname, /* getHostname */ +virGetHostname, /* getHostname */ NULL, /* getMaxVcpus */ nodeGetInfo, /* nodeGetInfo */ lxcGetCapabilities, /* getCapabilities */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 437a1b4..0470315 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2610,21 +2610,6 @@ cleanup: return ret; } -static char * -qemudGetHostname (virConnectPtr conn) -{ -char *result; - -result = virGetHostname(); -if (result == NULL) { -virReportSystemError (conn, errno, - %s, _(failed to determine host name)); -return NULL; -} -/* Caller frees this string. */ -return result; -} - static int qemudListDomains(virConnectPtr conn, int *ids, int nids) { struct qemud_driver *driver = conn-privateData; int n; @@ -6248,11 +6233,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0; /* Get hostname */ -if ((hostname = virGetHostname()) == NULL) { -virReportSystemError (dconn, errno, - %s, _(failed to determine host name)); +if ((hostname = virGetHostname(dconn)) == NULL) goto cleanup; -} /* XXX this really should have been a properly well-formed * URI, but we can't add in tcp:// now without breaking @@ -7084,7 +7066,7 @@ static virDriver qemuDriver = { qemudSupportsFeature, /* supports_feature */ qemudGetType, /* type */ qemudGetVersion, /* version */ -qemudGetHostname, /* getHostname */ +virGetHostname, /* getHostname */ qemudGetMaxVCPUs, /* getMaxVcpus */ nodeGetInfo, /* nodeGetInfo */ qemudGetCapabilities, /* getCapabilities */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7e19072..31b5ad3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1023,20 +1023,6 @@ static int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED, return (0); } -static char *testGetHostname (virConnectPtr conn) -{ -char *result; - -result = virGetHostname(); -if (result == NULL) { -virReportSystemError(conn, errno, - %s, _(cannot lookup hostname)); -return NULL; -} -/* Caller frees this string. */ -return result; -} - static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
[libvirt] [PATCH] Various error reporting fixes
- Don't duplicate SystemError - Use proper error code in domain_conf - Fix a broken error call in qemu_conf - Don't use VIR_ERR_ERROR in security driver (isn't a valid code in this case) Signed-off-by: Cole Robinson crobi...@redhat.com --- src/conf/domain_conf.c |2 +- src/conf/storage_conf.c |6 +++--- src/qemu/qemu_conf.c |6 ++ src/qemu/qemu_driver.c |2 +- src/security/security_apparmor.c | 30 +++--- src/security/security_driver.c |2 +- src/security/security_selinux.c | 10 +- src/xen/xen_hypervisor.c |4 +--- tests/cpuset |2 +- 9 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ba6b28d..ca141e1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3705,7 +3705,7 @@ virDomainCpuSetParse(virConnectPtr conn, const char **str, char sep, return (ret); parse_error: -virDomainReportError(conn, VIR_ERR_XEN_CALL, +virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, %s, _(topology cpuset syntax error)); return (-1); } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 2924a0d..065cd04 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1593,9 +1593,9 @@ virStoragePoolObjSaveDef(virConnectPtr conn, char path[PATH_MAX]; if ((err = virFileMakePath(driver-configDir))) { -virStorageReportError(conn, err, - _(cannot create config directory %s), - driver-configDir); +virReportSystemError(conn, err, + _(cannot create config directory %s), + driver-configDir); return -1; } diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 59873d7..71b3550 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1106,10 +1106,8 @@ int qemudExtractVersion(virConnectPtr conn, return -1; if (stat(binary, sb) 0) { -char ebuf[1024]; -qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _(Cannot find QEMU binary %s: %s), binary, - virStrerror(errno, ebuf, sizeof ebuf)); +virReportSystemError(conn, errno, + _(Cannot find QEMU binary %s), binary); return -1; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0470315..e8606c8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1773,7 +1773,7 @@ static int qemuDomainSetHostdevOwnership(virConnectPtr conn, } return 0; #else -qemudReportError(conn, NULL, NULL, %s, +qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, %s, _(unable to set host device ownership on this platform)); return -1; #endif diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index 16de0f2..6db51cd 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -112,7 +112,7 @@ profile_status_file(const char *str) if (snprintf(profile, PATH_MAX, %s/%s, APPARMOR_DIR /libvirt, str) PATH_MAX - 1) { -virSecurityReportError(NULL, VIR_ERR_ERROR, +virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR, %s, _(profile name exceeds maximum length)); } @@ -204,7 +204,7 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm, if (errno == EINTR) goto rewait; -virSecurityReportError(conn, VIR_ERR_ERROR, +virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR, _(Unexpected exit status from virt-aa-helper %d pid %lu), WEXITSTATUS(status), (unsigned long)child); @@ -265,7 +265,7 @@ use_apparmor(void) if ((len = readlink(/proc/self/exe, libvirt_daemon, PATH_MAX - 1)) 0) { -virSecurityReportError(NULL, VIR_ERR_ERROR, +virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR, %s, _(could not find libvirtd)); return rc; } @@ -289,13 +289,13 @@ AppArmorSecurityDriverProbe(void) /* see if template file exists */ if (snprintf(template, PATH_MAX, %s/TEMPLATE, APPARMOR_DIR /libvirt) PATH_MAX - 1) { -virSecurityReportError(NULL, VIR_ERR_ERROR, +virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR, %s, _(template too large)); return SECURITY_DRIVER_DISABLE; } if (!virFileExists(template)) { -virSecurityReportError(NULL, VIR_ERR_ERROR, +virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR, _(template \'%s\'
[libvirt] [PATCH] storage: conf: Fix memory leak in encryption parsing
Signed-off-by: Cole Robinson crobi...@redhat.com --- src/conf/storage_encryption_conf.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index b97b989..a329622 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -112,6 +112,7 @@ virStorageEncryptionSecretParse(virConnectPtr conn, xmlXPathContextPtr ctxt, uuidstr); goto cleanup; } +VIR_FREE(uuidstr); } else { virStorageReportError(conn, VIR_ERR_XML_ERROR, %s, _(missing volume encryption uuid)); -- 1.6.5.1 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/3] qemu: Use same create/define overwrite logic for migration
As pointed out by Dan here: https://www.redhat.com/archives/libvir-list/2009-October/msg00784.html We should be using the same logic for collision prevention and domain redefinition in the migrate routines as we use in create/define/restore. Cole Robinson (3): qemu: Remove compiled out localhost migration support qemu: Break out function to check if we can create/define/restore qemu: Use same create/define overwrite logic for migration prepare. src/qemu/qemu_driver.c | 191 1 files changed, 62 insertions(+), 129 deletions(-) -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/3] qemu: Remove compiled out localhost migration support
Pretty sure this would deadlock now that we have proper locking, so remove the code. Signed-off-by: Cole Robinson crobi...@redhat.com --- src/qemu/qemu_driver.c | 12 1 files changed, 0 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e8606c8..7eed356 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6298,20 +6298,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, /* Target domain name, maybe renamed. */ dname = dname ? dname : def-name; -#if 1 /* Ensure the name and UUID don't already exist in an active VM */ vm = virDomainFindByUUID(driver-domains, def-uuid); -#else -/* For TESTING ONLY you can change #if 1 - #if 0 above and use - * this code which lets you do localhost migrations. You must still - * supply a fresh 'dname' but this code assigns a random UUID. - */ -if (virUUIDGenerate (def-uuid) == -1) { -qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, -_(could not generate random UUID)); -goto cleanup; -} -#endif if (!vm) vm = virDomainFindByName(driver-domains, dname); if (vm) { -- 1.6.5.1 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] qemu: Break out function to check if we can create/define/restore
Signed-off-by: Cole Robinson crobi...@redhat.com --- src/qemu/qemu_driver.c | 151 +++- 1 files changed, 59 insertions(+), 92 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7eed356..e038887 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2594,6 +2594,59 @@ cleanup: return dom; } +static int +qemudDomainCanCreate(virConnectPtr conn, + virDomainDefPtr def, + unsigned int check_active) +{ +struct qemud_driver *driver = conn-privateData; +int ret = 0; +virDomainObjPtr vm = NULL; + +/* See if a VM with matching UUID already exists */ +vm = virDomainFindByUUID(driver-domains, def-uuid); +if (vm) { +/* UUID matches, but if names don't match, refuse it */ +if (STRNEQ(vm-def-name, def-name)) { +char uuidstr[VIR_UUID_STRING_BUFLEN]; +virUUIDFormat(vm-def-uuid, uuidstr); +qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, + _(domain '%s' is already defined with uuid %s), + vm-def-name, uuidstr); +goto cleanup; +} + +if (check_active) { +/* UUID name match, but if VM is already active, refuse it */ +if (virDomainObjIsActive(vm)) { +qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_INVALID, + _(domain is already active as '%s'), + vm-def-name); +goto cleanup; +} +} + +virDomainObjUnlock(vm); +} else { +/* UUID does not match, but if a name matches, refuse it */ +vm = virDomainFindByName(driver-domains, def-name); +if (vm) { +char uuidstr[VIR_UUID_STRING_BUFLEN]; +virUUIDFormat(vm-def-uuid, uuidstr); +qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, + _(domain '%s' already exists with uuid %s), + def-name, uuidstr); +goto cleanup; +} +} + +ret = 1; +cleanup: +if (vm) +virDomainObjUnlock(vm); +return ret; +} + static int qemudGetVersion(virConnectPtr conn, unsigned long *version) { struct qemud_driver *driver = conn-privateData; int ret = -1; @@ -2648,38 +2701,8 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml, if (virSecurityDriverVerify(conn, def) 0) goto cleanup; -/* See if a VM with matching UUID already exists */ -vm = virDomainFindByUUID(driver-domains, def-uuid); -if (vm) { -/* UUID matches, but if names don't match, refuse it */ -if (STRNEQ(vm-def-name, def-name)) { -char uuidstr[VIR_UUID_STRING_BUFLEN]; -virUUIDFormat(vm-def-uuid, uuidstr); -qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _(domain '%s' is already defined with uuid %s), - vm-def-name, uuidstr); -goto cleanup; -} - -/* UUID name match, but if VM is already active, refuse it */ -if (virDomainObjIsActive(vm)) { -qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _(domain is already active as '%s'), vm-def-name); -goto cleanup; -} -virDomainObjUnlock(vm); -} else { -/* UUID does not match, but if a name matches, refuse it */ -vm = virDomainFindByName(driver-domains, def-name); -if (vm) { -char uuidstr[VIR_UUID_STRING_BUFLEN]; -virUUIDFormat(vm-def-uuid, uuidstr); -qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _(domain '%s' is already defined with uuid %s), - def-name, uuidstr); -goto cleanup; -} -} +if (!qemudDomainCanCreate(conn, def, 1)) +goto cleanup; if (!(vm = virDomainAssignDef(conn, driver-caps, @@ -3709,38 +3732,8 @@ static int qemudDomainRestore(virConnectPtr conn, goto cleanup; } -/* See if a VM with matching UUID already exists */ -vm = virDomainFindByUUID(driver-domains, def-uuid); -if (vm) { -/* UUID matches, but if names don't match, refuse it */ -if (STRNEQ(vm-def-name, def-name)) { -char uuidstr[VIR_UUID_STRING_BUFLEN]; -virUUIDFormat(vm-def-uuid, uuidstr); -qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _(domain '%s' is already defined with uuid %s), - vm-def-name, uuidstr); -goto cleanup; -} - -/* UUID name match, but if VM is already active, refuse it */ -if (virDomainObjIsActive(vm)) { -
[libvirt] [PATCH 3/3] qemu: Use same create/define overwrite logic for migration prepare.
Signed-off-by: Cole Robinson crobi...@redhat.com --- src/qemu/qemu_driver.c | 30 -- 1 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e038887..6981d99 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6041,19 +6041,8 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, /* Target domain name, maybe renamed. */ dname = dname ? dname : def-name; -/* Ensure the name and UUID don't already exist in an active VM */ -vm = virDomainFindByUUID(driver-domains, def-uuid); - -if (!vm) vm = virDomainFindByName(driver-domains, dname); -if (vm) { -if (virDomainObjIsActive(vm)) { -qemudReportError(dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _(domain with the same name or UUID already exists as '%s'), - vm-def-name); -goto cleanup; -} -virDomainObjUnlock(vm); -} +if (!qemudDomainCanCreate(dconn, def, 1)) +goto cleanup; if (!(vm = virDomainAssignDef(dconn, driver-caps, @@ -6265,19 +6254,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, /* Target domain name, maybe renamed. */ dname = dname ? dname : def-name; -/* Ensure the name and UUID don't already exist in an active VM */ -vm = virDomainFindByUUID(driver-domains, def-uuid); - -if (!vm) vm = virDomainFindByName(driver-domains, dname); -if (vm) { -if (virDomainObjIsActive(vm)) { -qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _(domain with the same name or UUID already exists as '%s'), - vm-def-name); -goto cleanup; -} -virDomainObjUnlock(vm); -} +if (!qemudDomainCanCreate(dconn, def, 1)) +goto cleanup; if (!(vm = virDomainAssignDef(dconn, driver-caps, -- 1.6.5.1 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/6] test: Implement GetVcpus and PinVcpu
Using the recently committed support for driver specific domain data blobs[1], carry around VCPU pinning info for running test domains, which enables supporting GetVcpus and PinVcpu, which makes my life easier when adding support in virt-manager. [1] http://libvirt.org/git/?p=libvirt.git;a=commit;h=3505790b85da55c16191a9dca46404c29e0b7f87 Cole Robinson (6): test: Fixes for SetVcpus test: Break out wrapper for setting up started domain state. test: Use privateData to track running VM vcpu state test: Update vcpu runtime info in SetVcpus test: Implement virDomainGetVcpus test: Implement virDomainPinVcpu src/test/test_driver.c | 354 +--- 1 files changed, 337 insertions(+), 17 deletions(-) -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/6] test: Fixes for SetVcpus
- Implement DomainGetMaxVCPUs - Use GetMaxVCPUs to validate requested CPU amount - Deny the 'hotplug' for a running domain. Signed-off-by: Cole Robinson crobi...@redhat.com --- src/test/test_driver.c | 26 ++ 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 31b5ad3..2c61cf1 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1801,11 +1801,21 @@ cleanup: return ret; } +static int testDomainGetMaxVcpus(virDomainPtr domain) +{ +return testGetMaxVCPUs(domain-conn, test); +} + static int testSetVcpus(virDomainPtr domain, unsigned int nrCpus) { testConnPtr privconn = domain-conn-privateData; virDomainObjPtr privdom; -int ret = -1; +int ret = -1, maxvcpus; + +/* Do this first before locking */ +maxvcpus = testDomainGetMaxVcpus(domain); +if (maxvcpus 0) +goto cleanup; testDriverLock(privconn); privdom = virDomainFindByName(privconn-domains, @@ -1817,9 +1827,17 @@ static int testSetVcpus(virDomainPtr domain, goto cleanup; } +if (!virDomainIsActive(privdom)) { +testError(domain-conn, VIR_ERR_OPERATION_INVALID, + %s, _(cannot hotplug vcpus for an inactive domain)); +goto cleanup; +} + /* We allow more cpus in guest than host */ -if (nrCpus 32) { -testError(domain-conn, VIR_ERR_INVALID_ARG, __FUNCTION__); +if (nrCpus maxvcpus) { +testError(domain-conn, VIR_ERR_INVALID_ARG, + requested cpu amount exceeds maximum (%d %d), + nrCpus, maxvcpus); goto cleanup; } @@ -4686,7 +4704,7 @@ static virDriver testDriver = { testSetVcpus, /* domainSetVcpus */ NULL, /* domainPinVcpu */ NULL, /* domainGetVcpus */ -NULL, /* domainGetMaxVcpus */ +testDomainGetMaxVcpus, /* domainGetMaxVcpus */ NULL, /* domainGetSecurityLabel */ NULL, /* nodeGetSecurityModel */ testDomainDumpXML, /* domainDumpXML */ -- 1.6.5.1 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/6] test: Break out wrapper for setting up started domain state.
This should be a no op for now, but we will use this function to set up transient state in the future. Signed-off-by: Cole Robinson crobi...@redhat.com --- src/test/test_driver.c | 42 -- 1 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2c61cf1..8472e27 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -325,6 +325,17 @@ testDomainGenerateIfnames(virConnectPtr conn, return 0; } +static int +testDomainStartState(virConnectPtr conn, + virDomainObjPtr dom) +{ +testConnPtr privconn = conn-privateData; + +dom-state = VIR_DOMAIN_RUNNING; +dom-def-id = privconn-nextDomID++; + +return 0; +} static int testOpenDefault(virConnectPtr conn) { int u; @@ -391,8 +402,12 @@ static int testOpenDefault(virConnectPtr conn) { privconn-domains, domdef))) goto error; domdef = NULL; -domobj-def-id = privconn-nextDomID++; -domobj-state = VIR_DOMAIN_RUNNING; + +if (testDomainStartState(conn, domobj) 0) { +virDomainObjUnlock(domobj); +goto error; +} + domobj-persistent = 1; virDomainObjUnlock(domobj); @@ -746,8 +761,11 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } -dom-state = VIR_DOMAIN_RUNNING; -dom-def-id = privconn-nextDomID++; +if (testDomainStartState(conn, dom) 0) { +virDomainObjUnlock(dom); +goto error; +} + dom-persistent = 1; virDomainObjUnlock(dom); } @@ -1083,8 +1101,9 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, privconn-domains, def))) goto cleanup; def = NULL; -dom-state = VIR_DOMAIN_RUNNING; -dom-def-id = privconn-nextDomID++; + +if (testDomainStartState(conn, dom) 0) +goto cleanup; event = virDomainEventNewFromObj(dom, VIR_DOMAIN_EVENT_STARTED, @@ -1633,8 +1652,9 @@ static int testDomainRestore(virConnectPtr conn, goto cleanup; def = NULL; -dom-state = VIR_DOMAIN_RUNNING; -dom-def-id = privconn-nextDomID++; +if (testDomainStartState(conn, dom) 0) +goto cleanup; + event = virDomainEventNewFromObj(dom, VIR_DOMAIN_EVENT_STARTED, VIR_DOMAIN_EVENT_STARTED_RESTORED); @@ -1993,8 +2013,10 @@ static int testDomainCreate(virDomainPtr domain) { goto cleanup; } -domain-id = privdom-def-id = privconn-nextDomID++; -privdom-state = VIR_DOMAIN_RUNNING; +if (testDomainStartState(domain-conn, privdom) 0) +goto cleanup; +domain-id = privdom-def-id; + event = virDomainEventNewFromObj(privdom, VIR_DOMAIN_EVENT_STARTED, VIR_DOMAIN_EVENT_STARTED_BOOTED); -- 1.6.5.1 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/6] test: Use privateData to track running VM vcpu state
Signed-off-by: Cole Robinson crobi...@redhat.com --- src/test/test_driver.c | 135 +++- 1 files changed, 133 insertions(+), 2 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 8472e27..a8bec58 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -53,6 +53,15 @@ #define VIR_FROM_THIS VIR_FROM_TEST +/* Driver specific info to carry with a domain */ +struct _testDomainObjPrivate { +virVcpuInfoPtr vcpu_infos; + +unsigned char *cpumaps; +}; +typedef struct _testDomainObjPrivate testDomainObjPrivate; +typedef struct _testDomainObjPrivate *testDomainObjPrivatePtr; + #define MAX_CPUS 128 struct _testCell { @@ -126,6 +135,24 @@ static void testDriverUnlock(testConnPtr driver) virMutexUnlock(driver-lock); } +static void *testDomainObjPrivateAlloc(void) +{ +testDomainObjPrivatePtr priv; + +if (VIR_ALLOC(priv) 0) +return NULL; + +return priv; +} + +static void testDomainObjPrivateFree(void *data) +{ +testDomainObjPrivatePtr priv = data; + +VIR_FREE(priv); +} + + static virCapsPtr testBuildCapabilities(virConnectPtr conn) { testConnPtr privconn = conn-privateData; @@ -173,6 +200,9 @@ testBuildCapabilities(virConnectPtr conn) { goto no_memory; } +caps-privateDataAllocFunc = testDomainObjPrivateAlloc; +caps-privateDataFreeFunc = testDomainObjPrivateFree; + return caps; no_memory: @@ -269,7 +299,9 @@ static const char *defaultNodeXML = static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ull); static const unsigned long long defaultPoolAlloc = 0; -static int testStoragePoolObjSetDefaults(virConnectPtr conn, virStoragePoolObjPtr pool); +static int testStoragePoolObjSetDefaults(virConnectPtr conn, + virStoragePoolObjPtr pool); +static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); static char * testDomainGenerateIfname(virConnectPtr conn, @@ -325,16 +357,115 @@ testDomainGenerateIfnames(virConnectPtr conn, return 0; } +/* Helper to update info for a single VCPU */ +static int +testDomainUpdateVCPU(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainObjPtr dom, + int vcpu, + int maplen, + int maxcpu) +{ +testDomainObjPrivatePtr privdata = dom-privateData; +virVcpuInfoPtr info = privdata-vcpu_infos[vcpu]; +unsigned char *cpumap = VIR_GET_CPUMAP(privdata-cpumaps, maplen, vcpu); +int j; + +memset(info, 0, sizeof(virVcpuInfo)); +memset(cpumap, 0, maplen); + +info-number= vcpu; +info-state = VIR_VCPU_RUNNING; +info-cpuTime = 500; +info-cpu = 0; + +if (dom-def-cpumask) { +for (j = 0; j maxcpu j VIR_DOMAIN_CPUMASK_LEN; ++j) { +if (dom-def-cpumask[j]) { +VIR_USE_CPU(cpumap, j); +info-cpu = j; +} +} +} else { +for (j = 0; j maxcpu; ++j) { +if ((j % 3) == 0) { +/* Mark of every third CPU as usable */ +VIR_USE_CPU(cpumap, j); +info-cpu = j; +} +} +} + +return 0; +} + +/* + * Update domain VCPU amount and info + * + * @conn: virConnectPtr + * @dom : domain needing updates + * @nvcpus: New amount of vcpus for the domain + * @clear_all: If true, rebuild info for ALL vcpus, not just newly added vcpus + */ +static int +testDomainUpdateVCPUs(virConnectPtr conn, + virDomainObjPtr dom, + int nvcpus, + unsigned int clear_all) +{ +testConnPtr privconn = conn-privateData; +testDomainObjPrivatePtr privdata = dom-privateData; +int i, ret = -1; +int cpumaplen, maxcpu; + +maxcpu = VIR_NODEINFO_MAXCPUS(privconn-nodeInfo); +cpumaplen = VIR_CPU_MAPLEN(maxcpu); + +if (VIR_REALLOC_N(privdata-vcpu_infos, nvcpus) 0) { +virReportOOMError(conn); +goto cleanup; +} + +if (VIR_REALLOC_N(privdata-cpumaps, nvcpus * cpumaplen) 0) { +virReportOOMError(conn); +goto cleanup; +} + +/* Set running VCPU and cpumap state */ +if (clear_all) { +for (i = 0; i nvcpus; ++i) +if (testDomainUpdateVCPU(conn, dom, i, cpumaplen, maxcpu) 0) +goto cleanup; + +} else if (nvcpus dom-def-vcpus) { +/* VCPU amount has grown, populate info for the new vcpus */ +for (i = dom-def-vcpus; i nvcpus; ++i) +if (testDomainUpdateVCPU(conn, dom, i, cpumaplen, maxcpu) 0) +goto cleanup; +} + +ret = 0; +cleanup: +return ret; +} + +/* Set up domain runtime state */ static int testDomainStartState(virConnectPtr conn, virDomainObjPtr dom) { testConnPtr privconn = conn-privateData; +int ret = -1; + +if (testDomainUpdateVCPUs(conn, dom,
Re: [libvirt] [PATCH] network utilities: Add functions for address-text and get/set port number
I'm a bit behind the curve, but... On 11/02/2009 05:57 AM, Matthew Booth wrote: --- src/libvirt_private.syms |3 ++ src/util/network.c | 88 +- src/util/network.h |6 +++ 3 files changed, 96 insertions(+), 1 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8525dbd..15d75fd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -289,10 +289,13 @@ virFree; virSocketAddrInNetwork; virSocketAddrIsNetmask; virSocketCheckNetmask; +virSocketFormatAddr; +virSocketGetPort; virSocketGetRange; virSocketParseAddr; virSocketParseIpv4Addr; virSocketParseIpv6Addr; +virSocketSetPort; # network_conf.h diff --git a/src/util/network.c b/src/util/network.c index abd866c..094130f 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -9,6 +9,7 @@ */ #includeconfig.h +#includearpa/inet.h #include memory.h #include network.h @@ -64,7 +65,7 @@ static int getIPv6Addr(virSocketAddrPtr addr, virIPv6AddrPtr tab) { * Mostly a wrapper for getaddrinfo() extracting the address storage * from the numeric string like 1.2.3.4 or 2001:db8:85a3:0:0:8a2e:370:7334 * - * Returns the lenght of the network address or -1 in case of error. + * Returns the length of the network address or -1 in case of error. */ int virSocketParseAddr(const char *val, virSocketAddrPtr addr, int hint) { @@ -116,6 +117,91 @@ virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr) { return(virSocketParseAddr(val, addr, AF_INET6)); } +/* + * virSocketFormatAddr: + * @addr: an initialised virSocketAddrPtr + * + * Returns a string representation of the given address + * Returns NULL on any error + * Caller must free the returned string + */ +char * +virSocketFormatAddr(virSocketAddrPtr addr) { +char *out; +size_t outlen; +void *inaddr; + +if (addr-stor.ss_family == AF_INET) { +outlen = INET_ADDRSTRLEN; +inaddr =addr-inet4.sin_addr; +} + +else if (addr-stor.ss_family == AF_INET6) { +outlen = INET6_ADDRSTRLEN; +inaddr =addr-inet6.sin6_addr; +} + +else { +return NULL; +} + +if (VIR_ALLOC_N(out, outlen) 0) +return NULL; + +if (inet_ntop(addr-stor.ss_family, inaddr, out, outlen) == NULL) { +VIR_FREE(out); +return NULL; +} + +return out; +} + +/* + * virSocketSetPort: + * @addr: an initialised virSocketAddrPtr + * @port: the port number to set + * + * Set the transport layer port of the given virtSocketAddr + * + * Returns 0 on success, -1 on failure + */ +int +virSocketSetPort(virSocketAddrPtr addr, in_port_t port) { +if(addr-stor.ss_family == AF_INET) { +addr-inet4.sin_port = port; sin_port needs to be in network byte order. Unless you're figuring on the caller always remembering to do htons(), you might want to do it here. +} + +else if(addr-stor.ss_family == AF_INET6) { +addr-inet6.sin6_port = port; Likewise. +} + +else { +return -1; +} + +return 0; +} + +/* + * virSocketGetPort: + * @addr: an initialised virSocketAddrPtr + * + * Returns the transport layer port of the given virtSocketAddr + * Returns 0 if @addr is invalid + */ +in_port_t +virSocketGetPort(virSocketAddrPtr addr) { +if(addr-stor.ss_family == AF_INET) { +return addr-inet4.sin_port; Again, depending on how far you want this abstraction to go, you might want to do ntohs of sin_port. +} + +else if(addr-stor.ss_family == AF_INET6) { +return addr-inet6.sin6_port; Ditto. +} + +return 0; +} + /** * virSocketAddrIsNetmask: * @netmask: the netmask address diff --git a/src/util/network.h b/src/util/network.h index e590747..7618547 100644 --- a/src/util/network.h +++ b/src/util/network.h @@ -34,6 +34,12 @@ int virSocketParseIpv4Addr(const char *val, int virSocketParseIpv6Addr(const char *val, virSocketAddrPtr addr); +char * virSocketFormatAddr(virSocketAddrPtr addr); + +int virSocketSetPort(virSocketAddrPtr addr, in_port_t port); + +in_port_t virSocketGetPort(virSocketAddrPtr addr); + int virSocketAddrInNetwork(virSocketAddrPtr addr1, virSocketAddrPtr addr2, virSocketAddrPtr netmask); -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Add virConnectGetLibvirtVersion API
Hi all, The attached patch adds a new API call for retrieving the libvirt version used by a connection: virConnectGetLibvirtVersion. Without this, there is currently no way to determine the libvirt version of a remote qemu connection for example. This info can be useful for feature detection/enabling/disabling. As an example, virt-install may want to use the AC97 sound device as the default sound model for new VMs. However, this was only added to libvirt's white list in 0.6.0, while the other models have been available since 0.4.3. If installing a remote guest, virt-install will want to ensure that the remote libvirtd is = 0.6.0. Granted, the remote version could have backported the AC97 patch and virt-install would be incorrect, but better to be overly restrictive than to blindly specify AC97 and have guest creation bomb out. The 'correct' way to handle the above issue would be some combination of dropping internal whitelists from libvirt and generating them from info reported by the hypervisor, and advertising the available values in the capabilities XML. However I think this API addition makes things more manageable with little downside until a proper solution is implemented. Thanks, Cole commit 59871ddf8956a96a1148769c05ada6e763d91080 Author: Cole Robinson crobi...@redhat.com Date: Mon Nov 2 15:34:46 2009 -0500 Add virConnectGetLibvirtVersion There is currently no way to determine the libvirt version of a remote libvirtd we are connected to. This is a useful piece of data to enable feature detection. diff --git a/daemon/remote.c b/daemon/remote.c index 4296fc3..618954c 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -259,6 +259,26 @@ remoteDispatchGetVersion (struct qemud_server *server ATTRIBUTE_UNUSED, } static int +remoteDispatchGetLibvirtVersion (struct qemud_server *server ATTRIBUTE_UNUSED, + struct qemud_client *client ATTRIBUTE_UNUSED, + virConnectPtr conn, + remote_message_header *hdr ATTRIBUTE_UNUSED, + remote_error *rerr, + void *args ATTRIBUTE_UNUSED, + remote_get_libvirt_version_ret *ret) +{ +unsigned long libVer; + +if (virConnectGetLibvirtVersion (conn, libVer) == -1) { +remoteDispatchConnError(rerr, conn); +return -1; +} + +ret-lib_ver = libVer; +return 0; +} + +static int remoteDispatchGetHostname (struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h index 9afd2c7..85884b4 100644 --- a/daemon/remote_dispatch_prototypes.h +++ b/daemon/remote_dispatch_prototypes.h @@ -450,6 +450,14 @@ static int remoteDispatchGetHostname( remote_error *err, void *args, remote_get_hostname_ret *ret); +static int remoteDispatchGetLibvirtVersion( +struct qemud_server *server, +struct qemud_client *client, +virConnectPtr conn, +remote_message_header *hdr, +remote_error *err, +void *args, +remote_get_libvirt_version_ret *ret); static int remoteDispatchGetMaxVcpus( struct qemud_server *server, struct qemud_client *client, diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h index 6ced13a..020337e 100644 --- a/daemon/remote_dispatch_ret.h +++ b/daemon/remote_dispatch_ret.h @@ -106,3 +106,4 @@ remote_secret_get_xml_desc_ret val_remote_secret_get_xml_desc_ret; remote_secret_get_value_ret val_remote_secret_get_value_ret; remote_secret_lookup_by_usage_ret val_remote_secret_lookup_by_usage_ret; +remote_get_libvirt_version_ret val_remote_get_libvirt_version_ret; diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h index bb13f4c..c6db600 100644 --- a/daemon/remote_dispatch_table.h +++ b/daemon/remote_dispatch_table.h @@ -747,3 +747,8 @@ .args_filter = (xdrproc_t) xdr_remote_domain_migrate_prepare_tunnel_args, .ret_filter = (xdrproc_t) xdr_void, }, +{ /* GetLibvirtVersion = 149 */ +.fn = (dispatch_fn) remoteDispatchGetLibvirtVersion, +.args_filter = (xdrproc_t) xdr_void, +.ret_filter = (xdrproc_t) xdr_remote_get_libvirt_version_ret, +}, diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 6186d4e..9644538 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -489,6 +489,8 @@ int virConnectClose (virConnectPtr conn); const char *virConnectGetType (virConnectPtr conn); int virConnectGetVersion(virConnectPtr conn, unsigned long *hvVer); +int virConnectGetLibvirtVersion (virConnectPtr conn, +
[libvirt] [PATCH] Make monitor type (miimon/arpmon) optional in bond xml.
Lack of one of these in the live xml output was causing the parse to fail. --- src/conf/interface_conf.c | 35 +-- 1 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 31af957..31abf12 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -631,13 +631,17 @@ static int virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { xmlNodePtr node; -int ret = 0; +int ret = -1; unsigned long tmp; def-data.bond.mode = virInterfaceDefParseBondMode(conn, ctxt); if (def-data.bond.mode 0) goto error; +ret = virInterfaceDefParseBondItfs(conn, def, ctxt); +if (ret != 0) + goto error; + node = virXPathNode(conn, ./miimon[1], ctxt); if (node != NULL) { def-data.bond.monit = VIR_INTERFACE_BOND_MONIT_MII; @@ -669,15 +673,13 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, } def-data.bond.carrier = virInterfaceDefParseBondMiiCarrier(conn, ctxt); -if (def-data.bond.carrier 0) +if (def-data.bond.carrier 0) { +ret = -1; goto error; +} -ret = virInterfaceDefParseBondItfs(conn, def, ctxt); +} else if ((node = virXPathNode(conn, ./arpmon[1], ctxt)) != NULL) { -goto done; -} -node = virXPathNode(conn, ./arpmon[1], ctxt); -if (node != NULL) { def-data.bond.monit = VIR_INTERFACE_BOND_MONIT_ARP; ret = virXPathULong(conn, string(./arpmon/@interval), ctxt, tmp); @@ -693,23 +695,17 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def, if (def-data.bond.target == NULL) { virInterfaceReportError(conn, VIR_ERR_XML_ERROR, %s, _(bond interface arpmon target missing)); +ret = -1; goto error; } def-data.bond.validate = virInterfaceDefParseBondArpValid(conn, ctxt); -if (def-data.bond.validate 0) +if (def-data.bond.validate 0) { +ret = -1; goto error; - -ret = virInterfaceDefParseBondItfs(conn, def, ctxt); - -goto done; +} } - -virInterfaceReportError(conn, VIR_ERR_XML_ERROR, -%s, _(bond interface need miimon or arpmon element)); error: -ret = -1; -done: return(ret); } @@ -1109,11 +1105,6 @@ virInterfaceBondDefFormat(virConnectPtr conn, virBufferPtr buf, else if (def-data.bond.validate == VIR_INTERFACE_BOND_ARP_ALL) virBufferAddLit(buf, validate='all'); virBufferAddLit(buf, /\n); -} else { -virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR, -_(bond monitoring type %d unknown), -def-data.bond.monit); -return(-1); } for (i = 0;i def-data.bond.nbItf;i++) { if (virInterfaceBareDevDefFormat(conn, buf, def-data.bond.itf[i]) 0) -- 1.6.5.15.gc274d -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 10/21] Don't let parent of daemon exit until basic initialization is done
On Mon, Nov 02, 2009 at 05:05:55PM -0500, Cole Robinson wrote: On 10/23/2009 09:05 AM, Daniel P. Berrange wrote: The daemonizing code lets the parent exit almost immediately. This means that it may think it has successfully started even when important failures occur like not being able to acquire the PID file. It also means network sockets are not yet open. To address this when daemonizing the parent passes an open pipe file descriptor to the child. The child does its basic initialization and then writes a status code to the pipe indicating either success, or failure. This ensures that when daemonizing, the parent does not exit until the pidfile is acquired basic network sockets are open. Initialization of the libvirt drivers is still done asynchronously since this may take a very long time. * daemon/libvirtd.c: Force parent to stay around until basic config file, pidfile network socket init is completed +/* Start the stateful HV drivers + * This is delibrately done after telling the parent process + * we're ready, since it can take a long time and this will + * seriously delay OS bootup process */ +if (virStateInitialize(server-privileged) 0) { +VIR_ERROR0(Driver state initialization failed); +goto error; +} This breaks qemu:///session for me. Starting libvirtd by hand as a regular user, virStateInitialize tries to init lxc, but lxc explicitly denies non-root driver startup in lxc_driver.c:lxcStartup: /* Check that the user is root */ if (!privileged) { return -1; } Not sure what the proper fix is. Sorry, this was a rebase messup. The fix for this is in the next patch in the series - lxcStartup() should only return -1 for actual errors. Running unprivileged is not an error, it should merely disable itself and return 0. I'll apply the fix now. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] F12beta guest will not connect to LAN via bridge
Setup: HOST: F11 x86_64 GUEST: F12beta x86_64 I have a number of guests setup on this host and all connect without a problem with the 'br0' bridge on the host. I created a new guest and loaded F12beta on it. I defined it to also use 'br0' networking but this guest cannot ping anything on the LAN. All the other guests have no problems communicating to addresses on the LAN. Details: ### on HOST: # brctl showmacs br0 port no mac addris local? ageing timer 1 00:0b:82:11:bc:cb no15.88 3 00:0c:01:30:50:00 no16.37 2 00:0c:01:40:50:00 no 2.51 1 00:0c:29:e3:bc:ee no 0.49 1 00:18:f8:48:27:15 no 2.51 1 00:18:f8:9b:ba:b4 no 116.39 1 00:18:f8:9b:ba:b5 no20.60 1 00:1a:4d:5e:f6:36 no 156.43 1 00:24:1d:19:05:cf yes0.00 3 06:1d:1d:7a:31:9b yes0.00 2 06:ba:11:dd:7b:08 yes0.00 1 54:52:00:24:5e:cf no28.93 # EXISTING GUEST: network interface in xml file: interface type='bridge' mac address='00:0c:01:30:50:00'/ source bridge='br0'/ target dev='vnet0'/ model type='virtio'/ /interface # NEW GUEST: network interface in xml file: interface type='bridge' mac address='00:0c:01:40:50:00'/ source bridge='br0'/ target dev='vnet0'/ model type='virtio'/ /interface ### on EXISTING GUEST: DEVICE=eth0 ONBOOT=yes BOOTPROTO=static HWADDR=00:0c:01:30:50:00 IPADDR=192.168.1.200 NETMASK=255.255.255.0 NETWORK=192.168.1.0 ### on NEW GUEST: DEVICE=eth0 ONBOOT=yes BOOTPROTO=static HWADDR=00:0c:01:40:50:00 IPADDR=192.168.1.210 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 NETWORK=192.168.1.0 TYPE=Ethernet IPV6INIT=no USERCTL=no ### on EXISTING GUEST: # ping 192.168.1.1 succeeds ### on NEW GUEST: # ping 192.168.1.1 fails with Destination Host Unreachable Is there something else I need to configure in F12beta to get this working? -Gerry -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list