[libvirt] [PATCH V2] CI: also run tests using updated distro(s)
by claudioandre.br@gmail.com
From: Claudio André <claudioandre.br(a)gmail.com>
It is possible to test libvirt using other distros in Travis via Docker;
including (but not limited to) Fedora and Ubuntu.
---
See it in action at https://travis-ci.org/claudioandre/libvirt/builds/237687907
.travis.yml | 23 ++++++++++--------
tests/travis-ci.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 10 deletions(-)
create mode 100755 tests/travis-ci.sh
diff --git a/.travis.yml b/.travis.yml
index 5a3e765..3ed2093 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,6 @@
sudo: false
language: c
dist: precise
-compiler:
- - gcc
cache: ccache
addons:
apt:
@@ -62,15 +60,14 @@ git:
before_install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew install gnutls libgcrypt yajl gettext rpcgen ; fi
-# the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
-before_script:
- - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
script:
- - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+ - tests/travis-ci.sh
# Environments here are run in addition to the main environment defined above
matrix:
include:
+ - compiler: gcc
+ dist: precise
- compiler: clang
dist: precise
- compiler: clang
@@ -79,10 +76,16 @@ matrix:
dist: trusty
- compiler: clang
os: osx
- script:
- # many unit tests fail & so does syntax-check, so skip for now
- # one day we must fix it though....
- - make -j3
+ - services: docker
+ env: IMAGE=ubuntu:17.04 CCO=gcc
+ dist: trusty
+ - services: docker
+ env: IMAGE=ubuntu:17.04 CCO=clang
+ dist: trusty
+
+ allow_failures:
+ - env: IMAGE=ubuntu:17.04 CCO=gcc
+ - env: IMAGE=ubuntu:17.04 CCO=clang
after_failure:
- echo '============================================================================'
diff --git a/tests/travis-ci.sh b/tests/travis-ci.sh
new file mode 100755
index 0000000..07ec85d
--- /dev/null
+++ b/tests/travis-ci.sh
@@ -0,0 +1,70 @@
+#!/bin/bash -e
+
+function do_Install_Dependencies(){
+ echo
+ echo '-- Installing Dependencies --'
+
+ apt-get update -qq
+ apt-get -y -qq install \
+ build-essential git clang autoconf libtool libcmpicppimpl0 gettext \
+ xsltproc autopoint libxml2-dev libncurses5-dev libreadline-dev \
+ zlib1g-dev libgnutls28-dev libgcrypt11-dev libavahi-client-dev libsasl2-dev \
+ libxen-dev lvm2 libgcrypt11-dev libparted0-dev libdevmapper-dev uuid-dev \
+ libudev-dev libpciaccess-dev libcap-ng-dev libnl-3-dev libnl-route-3-dev \
+ libyajl-dev libpcap0.8-dev libnuma-dev libnetcf-dev libaudit-dev \
+ libxml2-utils libapparmor-dev dnsmasq-base librbd-dev w3c-markup-validator kmod > /dev/null
+}
+
+
+function do_Show_Info(){
+ echo
+ echo '-- Environment --'
+ echo "Running on Docker: $DISTRO"
+ id
+ uname -a
+}
+
+
+function do_Show_Compiler(){
+
+ if [[ -n $CC ]]; then
+ echo
+ echo '-- Compiler in use --'
+ "$CC" --version
+ fi
+}
+
+
+# ----------- Build and Test libvirt -----------
+
+if [[ -n $IMAGE ]]; then
+ # Run docker using the selected image; then build and test
+ docker run --privileged --cap-add=ALL -v /lib/modules:/lib/modules \
+ -v "$(pwd)":/cwd -e CC=$CCO -e DISTRO=$IMAGE "$IMAGE" sh -e -c " \
+ cd /cwd; \
+ tests/travis-ci.sh"
+ exit $?
+fi
+
+if [[ -n $DISTRO ]]; then
+ do_Show_Info
+ do_Install_Dependencies
+ do_Show_Compiler
+fi
+
+echo -en 'travis_fold:start:autogen\r'
+ echo '-- Running ./autogen.sh --'
+ # The custom PATH is just to pick up OS-X homebrew & its harmless on Linux
+ PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
+echo -en 'travis_fold:end:autogen\r'
+
+# Build and test
+if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
+ # many unit tests fail & so does syntax-check, so skip for now
+ # one day we must fix it though....
+ make -j3
+else
+ VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+fi
+
+exit $?
--
2.11.0
7 years, 5 months
[libvirt] [PATCH] virsh: add --domain option for domain-to-native
by Daniel Liu
Fix bug 835476[1].
virsh: add [--domain DOMAIN] option to domxml-to-native DOMAIN COMMAND
Add support for the following syntax:
domxml-to-native <format> { [--domain DOMAIN] | [XML] }, i.e., it supports
either designating domain (domain id, uuid, or name), or path to XML domain
configuration file.
E.g.:
virsh domxml-to-native qemu-argv --domain RHEL7.3 # domain name
virsh domxml-to-native qemu-argv --domain 10 # domain id
virsh domxml-to-native qemu-argv dumped_dom.xml # dumped xml
[1] https://bugzilla.redhat.com/show_bug.cgi?id=835476
---
tools/virsh-domain.c | 54 ++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 10 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0d19d0e01..a79fd3ab2 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9840,9 +9840,13 @@ static const vshCmdOptDef opts_domxmltonative[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("target config data type format")
},
+ {.name = "domain",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ_OPT,
+ .help = N_("domain name, id or uuid")
+ },
{.name = "xml",
.type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
.help = N_("xml data file to export from")
},
{.name = NULL}
@@ -9851,30 +9855,60 @@ static const vshCmdOptDef opts_domxmltonative[] = {
static bool
cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
{
- bool ret = true;
+ bool ret = false;
const char *format = NULL;
- const char *xmlFile = NULL;
- char *configData;
- char *xmlData;
+ const char *domain = NULL;
+ const char *xml = NULL;
+ char *xmlData = NULL;
+ char *configData = NULL;
unsigned int flags = 0;
virshControlPtr priv = ctl->privData;
+ virDomainPtr dom = NULL;
- if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0)
+ if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0)
+ return false;
+
+ if (vshCommandOptStringReq(ctl, cmd, "domain", &domain) < 0)
+ return false;
+
+ if (vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0)
return false;
- if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0)
+ VSH_EXCLUSIVE_OPTIONS_VAR(domain, xml);
+
+ if (domain)
+ dom = virshCommandOptDomain(ctl, cmd, &domain);
+
+ if (!dom && !xml) {
+ vshError(ctl, _("need either domain (ID, UUID, or name) or domain XML configuration file path"));
return false;
+ }
+
+ if (dom) {
+ xmlData = virDomainGetXMLDesc(dom, flags);
+ if (xmlData == NULL)
+ goto cleanup;
+ }
+
+ if (xml) {
+ if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlData) < 0)
+ goto cleanup;
+ }
configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags);
if (configData != NULL) {
vshPrint(ctl, "%s", configData);
- VIR_FREE(configData);
+ ret = true;
+ goto cleanup;
} else {
- ret = false;
+ vshError(ctl, _("convert from domain XML to native command failed"));
+ goto cleanup;
}
+ cleanup:
+ virshDomainFree(dom);
VIR_FREE(xmlData);
+ VIR_FREE(configData);
return ret;
}
--
2.13.0
7 years, 5 months
[libvirt] [PATCH v3] virsh: add [--domain DOMAIN] option to domxml-to-native DOMAIN COMMAND
by Daniel Liu
The option allows someone to run domain-to-native on already existing
domain without the need of supplying their XML. It is basically
wrapper around 'virsh dumpxml | virsh domxml-to-native /dev/stdin'.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=835476
---
tools/virsh-domain.c | 53 +++++++++++++++++++++++++++++++++++++++-------------
tools/virsh.pod | 7 ++++---
2 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index ccb514ef9..db92c4478 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9848,9 +9848,13 @@ static const vshCmdOptDef opts_domxmltonative[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("target config data type format")
},
+ {.name = "domain",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ_OPT,
+ .help = N_("domain name, id or uuid")
+ },
{.name = "xml",
.type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
.help = N_("xml data file to export from")
},
{.name = NULL}
@@ -9859,30 +9863,53 @@ static const vshCmdOptDef opts_domxmltonative[] = {
static bool
cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
{
- bool ret = true;
+ bool ret = false;
const char *format = NULL;
- const char *xmlFile = NULL;
- char *configData;
- char *xmlData;
+ const char *xml = NULL;
+ char *xmlData = NULL;
+ char *configData = NULL;
unsigned int flags = 0;
virshControlPtr priv = ctl->privData;
+ virDomainPtr dom = NULL;
if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0)
+ vshCommandOptStringReq(ctl, cmd, "xml", &xml) < 0)
return false;
- if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0)
- return false;
+ VSH_EXCLUSIVE_OPTIONS("domain", "xml");
- configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags);
- if (configData != NULL) {
- vshPrint(ctl, "%s", configData);
- VIR_FREE(configData);
+ if (vshCommandOptBool(cmd, "domain") &&
+ (!(dom = virshCommandOptDomain(ctl, cmd, NULL))))
+ return false;
+
+ if (dom) {
+ xmlData = virDomainGetXMLDesc(dom, flags);
+ } else if (xml) {
+ if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlData) < 0)
+ goto cleanup;
} else {
- ret = false;
+ vshError(ctl, "%s", _("need either domain or domain XML"));
+ goto cleanup;
+ }
+
+ if (!xmlData) {
+ vshError(ctl, "%s", _("failed to retrieve XML"));
+ goto cleanup;
+ }
+
+ if (!(configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags))) {
+ vshError(ctl, "%s",
+ _("convert from domain XML to native command failed"));
+ goto cleanup;
+ } else {
+ vshPrint(ctl, "%s", configData);
+ ret = true;
}
+ cleanup:
+ virshDomainFree(dom);
VIR_FREE(xmlData);
+ VIR_FREE(configData);
return ret;
}
diff --git a/tools/virsh.pod b/tools/virsh.pod
index aee964689..049c2f3c7 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1433,10 +1433,11 @@ the I<format> argument must be B<qemu-argv>. For Xen hypervisor, the
I<format> argument may be B<xen-xm>, B<xen-xl>, or B<xen-sxpr>. For
LXC hypervisor, the I<format> argument must be B<lxc-tools>.
-=item B<domxml-to-native> I<format> I<xml>
+=item B<domxml-to-native> I<format>
+{ I<--domain> I<domain-name-or-id-or-uuid> | [I<--xml>] I<xml> }
-Convert the file I<xml> in domain XML format to the native guest
-configuration format named by I<format>. For QEMU/KVM hypervisor,
+Convert the file I<xml> in domain XML format or existing domain to the
+native guest configuration format named by I<format>. For QEMU/KVM hypervisor,
the I<format> argument must be B<qemu-argv>. For Xen hypervisor, the
I<format> argument may be B<xen-xm>, B<xen-xl>, or B<xen-sxpr>. For
LXC hypervisor, the I<format> argument must be B<lxc-tools>.
--
2.13.0
7 years, 5 months
[libvirt] [PATCH] CI: also run tests using updated distro(s)
by claudioandre.br@gmail.com
From: Claudio André <claudioandre.br(a)gmail.com>
It is possible to test libvirt using other distros in Travis via Docker; including (but not limited to) Fedora and Ubuntu.
---
Notes:
* see it working at: https://travis-ci.org/claudioandre/libvirt/builds/237015534
* now, I introduced an error: https://travis-ci.org/claudioandre/libvirt/builds/237018298
* I'm using Ubuntu 17.04 because I need to pick something. Could be Xenial and/or Fedora and/or ...;
* One test is failing in Ubuntu 17.04 in Travis. The error log says:
-----
TEST: virkmodtest
Failed to get config
!... 4 FAIL
FAIL virkmodtest (exit status: 1)
-----
* Since it is failing, I used the 'allow_failures'.
.travis.yml | 19 +++++++++-------
tests/travis-ci.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 8 deletions(-)
create mode 100755 tests/travis-ci.sh
diff --git a/.travis.yml b/.travis.yml
index 5a3e765..7b73761 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -62,11 +62,8 @@ git:
before_install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew install gnutls libgcrypt yajl gettext rpcgen ; fi
-# the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
-before_script:
- - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
script:
- - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+ - tests/travis-ci.sh
# Environments here are run in addition to the main environment defined above
matrix:
@@ -79,10 +76,16 @@ matrix:
dist: trusty
- compiler: clang
os: osx
- script:
- # many unit tests fail & so does syntax-check, so skip for now
- # one day we must fix it though....
- - make -j3
+ - services: docker
+ env: IMAGE=ubuntu:17.04 CCO=gcc
+ dist: trusty
+ - services: docker
+ env: IMAGE=ubuntu:17.04 CCO=clang
+ dist: trusty
+
+ allow_failures:
+ - env: IMAGE=ubuntu:17.04 CCO=gcc
+ - env: IMAGE=ubuntu:17.04 CCO=clang
after_failure:
- echo '============================================================================'
diff --git a/tests/travis-ci.sh b/tests/travis-ci.sh
new file mode 100755
index 0000000..d115564
--- /dev/null
+++ b/tests/travis-ci.sh
@@ -0,0 +1,64 @@
+#!/bin/bash -e
+
+function do_Install_Dependencies(){
+ echo
+ echo '-- Installing Dependencies --'
+
+ apt-get update -qq
+ apt-get -y -qq install \
+ build-essential git clang autoconf libtool libcmpicppimpl0 gettext \
+ xsltproc autopoint libxml2-dev libncurses5-dev libreadline-dev \
+ zlib1g-dev libgnutls28-dev libgcrypt11-dev libavahi-client-dev libsasl2-dev \
+ libxen-dev lvm2 libgcrypt11-dev libparted0-dev libdevmapper-dev uuid-dev \
+ libudev-dev libpciaccess-dev libcap-ng-dev libnl-3-dev libnl-route-3-dev \
+ libyajl-dev libpcap0.8-dev libnuma-dev libnetcf-dev libaudit-dev \
+ libxml2-utils libapparmor-dev dnsmasq-base librbd-dev w3c-markup-validator
+}
+
+
+function do_Show_Info(){
+ echo
+ echo '-- Environment --'
+ echo "Running on Docker: $DISTRO"
+}
+
+
+function do_Show_Compiler(){
+
+ if [[ -n $CC ]]; then
+ echo
+ echo '-- Compiler in use --'
+ "$CC" --version
+ fi
+}
+
+
+# ----------- Build and Test libvirt -----------
+
+if [[ -n $IMAGE ]]; then
+ # Run docker using the selected image; then build and test
+ docker run -v "$(pwd)":/cwd -e CC=$CCO -e DISTRO=$IMAGE "$IMAGE" sh -e -c " \
+ cd /cwd; \
+ tests/travis-ci.sh"
+ exit $?
+fi
+
+if [[ -n $DISTRO ]]; then
+ do_Show_Info
+ do_Install_Dependencies
+ do_Show_Compiler
+fi
+
+# The custom PATH is just to pick up OS-X homebrew & its harmless on Linux
+PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
+
+# Build and test
+if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
+ # many unit tests fail & so does syntax-check, so skip for now
+ # one day we must fix it though....
+ make -j3
+else
+ VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
+fi
+
+exit $?
--
2.11.0
7 years, 5 months
[libvirt] [PATCH] qemu: mkdir memory_backing_dir on startup
by Michal Privoznik
In 48d9e6cdcc and friends we've allowed users to back guest
memory by a file inside the host. And in order to keep things
manageable the memory_backing_dir variable was introduced to
qemu.conf to specify the directory where the files are kept.
However, libvirt's policy is that directories are created on
domain startup if they don't exist. We've missed this one.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_driver.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 67f54282a..fcab7ddf8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -706,6 +706,11 @@ qemuStateInitialize(bool privileged,
cfg->nvramDir);
goto error;
}
+ if (virFileMakePath(cfg->memoryBackingDir) < 0) {
+ virReportSystemError(errno, _("Failed to create memory backing dir %s"),
+ cfg->memoryBackingDir);
+ goto error;
+ }
qemu_driver->qemuImgBinary = virFindFileInPath("qemu-img");
@@ -830,6 +835,13 @@ qemuStateInitialize(bool privileged,
(int) cfg->group);
goto error;
}
+ if (chown(cfg->memoryBackingDir, cfg->user, cfg->group) < 0) {
+ virReportSystemError(errno,
+ _("unable to set ownership of '%s' to %d:%d"),
+ cfg->memoryBackingDir, (int) cfg->user,
+ (int) cfg->group);
+ goto error;
+ }
run_uid = cfg->user;
run_gid = cfg->group;
--
2.13.0
7 years, 5 months
[libvirt] [PATCH v4 0/5] Hyperv-method invocation
by Sri Ramanujam
Changes from v3:
* Feedback from code review
* Added 5 minute timeout to hypervInvokeMethod
Sri Ramanujam (5):
hyperv: Functions to work with invocation parameters.
hyperv: Generate object property type information.
hyperv: add hypervInvokeMethod
hyperv: support virDomainSendKey
hyperv: Add support for virDomainSetMemory
src/hyperv/hyperv_driver.c | 201 ++++++++
src/hyperv/hyperv_wmi.c | 894 ++++++++++++++++++++++++++++++++++
src/hyperv/hyperv_wmi.h | 93 +++-
src/hyperv/hyperv_wmi_classes.h | 19 +
src/hyperv/hyperv_wmi_generator.input | 116 +++++
src/hyperv/hyperv_wmi_generator.py | 15 +-
src/hyperv/openwsman.h | 4 +
7 files changed, 1340 insertions(+), 2 deletions(-)
--
2.9.4
7 years, 5 months
[libvirt] [PATCH go-xml] Add support for Node Device with basic testing.
by Vladik Romanovsky
---
node_device.go | 277 ++++++++++++++++++++++++++++++++++++++++++++++++++++
node_device_test.go | 111 +++++++++++++++++++++
2 files changed, 388 insertions(+)
create mode 100644 node_device.go
create mode 100644 node_device_test.go
diff --git a/node_device.go b/node_device.go
new file mode 100644
index 0000000..5375d32
--- /dev/null
+++ b/node_device.go
@@ -0,0 +1,277 @@
+/*
+ * This file is part of the libvirt-go-xml project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ */
+
+package libvirtxml
+
+import (
+ "encoding/xml"
+ "fmt"
+)
+
+type NodeDevice struct {
+ Name string `xml:"name"`
+ Path string `xml:"path,omitempty"`
+ Parent string `xml:"parent,omitempty"`
+ Driver string `xml:"driver>name,omitempty"`
+ Capability *CapabilityType `xml:"capability"`
+}
+
+type CapabilityType struct {
+ Type interface{} `xml:"type,attr"`
+}
+
+type IDName struct {
+ ID string `xml:"id,attr"`
+ Name string `xml:",chardata"`
+}
+
+type PciExpress struct {
+ Links []PciExpressLink `xml:"link"`
+}
+
+type PciExpressLink struct {
+ Validity string `xml:"validity,attr,omitempty"`
+ Speed float64 `xml:"speed,attr,omitempty"`
+ Port int `xml:"port,attr,omitempty"`
+ Width int `xml:"width,attr,omitempty"`
+}
+
+type IOMMUGroupType struct {
+ Number int `xml:"number,attr"`
+}
+
+type NUMA struct {
+ Node int `xml:"node,attr"`
+}
+
+type PciCapabilityType struct {
+ Domain int `xml:"domain,omitempty"`
+ Bus int `xml:"bus,omitempty"`
+ Slot int `xml:"slot,omitempty"`
+ Function int `xml:"function,omitempty"`
+ Product IDName `xml:"product,omitempty"`
+ Vendor IDName `xml:"vendor,omitempty"`
+ IommuGroup IOMMUGroupType `xml:"iommuGroup,omitempty"`
+ Numa NUMA `xml:"numa,omitempty"`
+ PciExpress PciExpress `xml:"pci-express,omitempty"`
+ Capabilities []PciCapability `xml:"capability,omitempty"`
+}
+
+type PCIAddress struct {
+ Domain string `xml:"domain,attr"`
+ Bus string `xml:"bus,attr"`
+ Slot string `xml:"slot,attr"`
+ Function string `xml:"function,attr"`
+}
+
+type PciCapability struct {
+ Type string `xml:"type,attr"`
+ Address []PCIAddress `xml:"address,omitempty"`
+ MaxCount int `xml:"maxCount,attr,omitempty"`
+}
+
+type SystemHardware struct {
+ Vendor string `xml:"vendor"`
+ Version string `xml:"version"`
+ Serial string `xml:"serial"`
+ UUID string `xml:"uuid"`
+}
+
+type SystemFirmware struct {
+ Vendor string `xml:"vendor"`
+ Version string `xml:"version"`
+ ReleaseData string `xml:"release_date"`
+}
+
+type SystemCapabilityType struct {
+ Product string `xml:"product"`
+ Hardware SystemHardware `xml:"hardware"`
+ Firmware SystemFirmware `xml:"firmware"`
+}
+
+type USBDeviceCapabilityType struct {
+ Bus int `xml:"bus"`
+ Device int `xml:"device"`
+ Product IDName `xml:"product,omitempty"`
+ Vendor IDName `xml:"vendor,omitempty"`
+}
+
+type USBCapabilityType struct {
+ Number int `xml:"number"`
+ Class int `xml:"class"`
+ Subclass int `xml:"subclass"`
+ Protocol int `xml:"protocol"`
+ Description string `xml:"description,omitempty"`
+}
+
+type NetOffloadFeatures struct {
+ Name string `xml:"number"`
+}
+
+type NetLink struct {
+ State string `xml:"state,attr"`
+ Speed string `xml:"speed,attr,omitempty"`
+}
+
+type NetCapability struct {
+ Type string `xml:"type,attr"`
+}
+
+type NetCapabilityType struct {
+ Interface string `xml:"interface"`
+ Address string `xml:"address"`
+ Link NetLink `xml:"link"`
+ Features []NetOffloadFeatures `xml:"feature,omitempty"`
+ Capability NetCapability `xml:"capability"`
+}
+
+type SCSIVportsOPS struct {
+ Vports int `xml:"vports,omitempty"`
+ MaxVports int `xml:"maxvports,,omitempty"`
+}
+
+type SCSIFCHost struct {
+ WWNN string `xml:"wwnn,omitempty"`
+ WWPN string `xml:"wwpn,omitempty"`
+ FabricWWN string `xml:"fabric_wwn,omitempty"`
+}
+
+type SCSIHostCapability struct {
+ VportsOPS SCSIVportsOPS `xml:"vports_ops"`
+ FCHost SCSIFCHost `xml:"fc_host"`
+}
+
+type SCSIHostCapabilityType struct {
+ Host int `xml:"host"`
+ UniqueID int `xml:"unique_id"`
+ Capability SCSIHostCapability `xml:"capability"`
+}
+
+type SCSICapabilityType struct {
+ Host int `xml:"host"`
+ Bus int `xml:"bus"`
+ Target int `xml:"target"`
+ Lun int `xml:"lun"`
+ Type string `xml:"type"`
+}
+
+type StroageCap struct {
+ Type string `xml:"match,attr"`
+ MediaAvailable int `xml:"media_available,omitempty"`
+ MediaSize int `xml:"media_size,omitempty"`
+ MediaLable int `xml:"media_label,omitempty"`
+}
+
+type StorageCapabilityType struct {
+ Block string `xml:"block"`
+ Bus string `xml:"bus"`
+ DriverType string `xml:"drive_type"`
+ Model string `xml:"model"`
+ Vendor string `xml:"vendor"`
+ Serial string `xml:"serial"`
+ Size int `xml:"size"`
+ Capatibility StroageCap `xml:"capability,omitempty"`
+}
+
+type DRMCapabilityType struct {
+ Type string `xml:"type"`
+}
+
+func (c *CapabilityType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
+ for _, attr := range start.Attr {
+ fmt.Println(attr.Name.Local)
+ if attr.Name.Local == "type" {
+ switch attr.Value {
+ case "pci":
+ var pciCaps PciCapabilityType
+ if err := d.DecodeElement(&pciCaps, &start); err != nil {
+ return err
+ }
+ c.Type = pciCaps
+ case "system":
+ var systemCaps SystemCapabilityType
+ if err := d.DecodeElement(&systemCaps, &start); err != nil {
+ return err
+ }
+ c.Type = systemCaps
+ case "usb_device":
+ var usbdevCaps USBDeviceCapabilityType
+ if err := d.DecodeElement(&usbdevCaps, &start); err != nil {
+ return err
+ }
+ c.Type = usbdevCaps
+ case "usb":
+ var usbCaps USBCapabilityType
+ if err := d.DecodeElement(&usbCaps, &start); err != nil {
+ return err
+ }
+ c.Type = usbCaps
+ case "net":
+ var netCaps NetCapabilityType
+ if err := d.DecodeElement(&netCaps, &start); err != nil {
+ return err
+ }
+ c.Type = netCaps
+ case "scsi_host":
+ var scsiHostCaps SCSIHostCapabilityType
+ if err := d.DecodeElement(&scsiHostCaps, &start); err != nil {
+ return err
+ }
+ c.Type = scsiHostCaps
+ case "scsi":
+ var scsiCaps SCSICapabilityType
+ if err := d.DecodeElement(&scsiCaps, &start); err != nil {
+ return err
+ }
+ c.Type = scsiCaps
+ case "storage":
+ var storageCaps StorageCapabilityType
+ if err := d.DecodeElement(&storageCaps, &start); err != nil {
+ return err
+ }
+ c.Type = storageCaps
+ case "drm":
+ var drmCaps DRMCapabilityType
+ if err := d.DecodeElement(&drmCaps, &start); err != nil {
+ return err
+ }
+ c.Type = drmCaps
+ }
+ }
+ }
+ return nil
+}
+
+func (c *NodeDevice) Unmarshal(doc string) error {
+ return xml.Unmarshal([]byte(doc), c)
+}
+
+func (c *NodeDevice) Marshal() (string, error) {
+ doc, err := xml.MarshalIndent(c, "", " ")
+ if err != nil {
+ return "", err
+ }
+ return string(doc), nil
+}
diff --git a/node_device_test.go b/node_device_test.go
new file mode 100644
index 0000000..129956b
--- /dev/null
+++ b/node_device_test.go
@@ -0,0 +1,111 @@
+/*
+ * This file is part of the libvirt-go-xml project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ */
+
+package libvirtxml
+
+import (
+ "reflect"
+ "strings"
+ "testing"
+)
+
+var NodeDeviceTestData = []struct {
+ Object *NodeDevice
+ XML []string
+}{
+ {
+ Object: &NodeDevice{
+ Name: "pci_0000_81_00_0",
+ Parent: "pci_0000_80_01_0",
+ Driver: "ixgbe",
+ Capability: &CapabilityType{
+ Type: PciCapabilityType{
+ Domain: 1,
+ Bus: 21,
+ Slot: 10,
+ Function: 50,
+ Product: IDName{
+ ID: "0x1528",
+ Name: "Ethernet Controller 10-Gigabit X540-AT2",
+ },
+ Vendor: IDName{
+ ID: "0x8086",
+ Name: "Intel Corporation",
+ },
+ IommuGroup: IOMMUGroupType{
+ Number: 3,
+ },
+ Numa: NUMA{
+ Node: 1,
+ },
+ Capabilities: []PciCapability{
+ PciCapability{
+ Type: "virt_functions",
+ MaxCount: 63,
+ },
+ },
+ },
+ },
+ },
+ XML: []string{
+ `<device>`,
+ ` <name>pci_0000_81_00_0</name>`,
+ ` <parent>pci_0000_80_01_0</parent>`,
+ ` <driver>`,
+ ` <name>ixgbe</name>`,
+ ` </driver>`,
+ ` <capability type='pci'>`,
+ ` <domain>1</domain>`,
+ ` <bus>21</bus>`,
+ ` <slot>10</slot>`,
+ ` <function>50</function>`,
+ ` <product id='0x1528'>Ethernet Controller 10-Gigabit X540-AT2</product>`,
+ ` <vendor id='0x8086'>Intel Corporation</vendor>`,
+ ` <capability type='virt_functions' maxCount='63'/>`,
+ ` <iommuGroup number='3'>`,
+ ` <address domain='0x0000' bus='0x15' slot='0x00' function='0x4'/>`,
+ ` </iommuGroup>`,
+ ` <numa node='1'/>`,
+ ` </capability>`,
+ `</device>`,
+ },
+ },
+}
+
+func TestNodeDevice(t *testing.T) {
+ for _, test := range NodeDeviceTestData {
+ xmlDoc := strings.Join(test.XML, "\n")
+ nodeDevice := NodeDevice{}
+ err := nodeDevice.Unmarshal(xmlDoc)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ res := reflect.DeepEqual(&nodeDevice, test.Object)
+ if !res {
+ t.Fatal("Bad NodeDevice object creation.")
+ }
+ }
+}
--
2.9.4
7 years, 5 months
[libvirt] [PATCH go-xml] 1, add support for disk cache and io, and add test case. 2, add support for controller model, and add test case. 3, extend DomainAddress struct for PCI address and target&unit, and add test cases. 4, modify DomainController:Index type from string to *uint.
by zhenwei.pi
---
domain.go | 13 +++++++++++--
domain_test.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 64 insertions(+), 5 deletions(-)
diff --git a/domain.go b/domain.go
index 848835a..cbb22e5 100644
--- a/domain.go
+++ b/domain.go
@@ -30,8 +30,10 @@ import (
)
type DomainController struct {
- Type string `xml:"type,attr"`
- Index string `xml:"index,attr"`
+ Type string `xml:"type,attr"`
+ Index *uint `xml:"index,attr"`
+ Model string `xml:"model,attr,omitempty"`
+ Address *DomainAddress `xml:"address"`
}
type DomainDiskSecret struct {
@@ -77,6 +79,8 @@ type DomainDisk struct {
Type string `xml:"type,attr"`
Device string `xml:"device,attr"`
Snapshot string `xml:"snapshot,attr,omitempty"`
+ Cache string `xml:"cache,attr,omitempty"`
+ Io string `xml:"io,attr,omitempty"`
Driver *DomainDiskDriver `xml:"driver"`
Auth *DomainDiskAuth `xml:"auth"`
Source *DomainDiskSource `xml:"source"`
@@ -196,8 +200,13 @@ type DomainAlias struct {
type DomainAddress struct {
Type string `xml:"type,attr"`
Controller *uint `xml:"controller,attr"`
+ Domain *uint `xml:"domain,attr"`
Bus *uint `xml:"bus,attr"`
Port *uint `xml:"port,attr"`
+ Slot *uint `xml:"slot,attr"`
+ Function *uint `xml:"function,attr"`
+ Target *uint `xml:"target,attr"`
+ Unit *uint `xml:"unit,attr"`
}
type DomainChardev struct {
diff --git a/domain_test.go b/domain_test.go
index 265cf80..22da947 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -30,6 +30,16 @@ import (
"testing"
)
+type PciAddress struct {
+ Domain uint
+ Bus uint
+ Slot uint
+ Function uint
+}
+
+var uhciIndex uint = 0
+var uhciAddr = PciAddress{0, 0, 1, 2}
+
var domainTestData = []struct {
Object *Domain
Expected []string
@@ -130,10 +140,12 @@ var domainTestData = []struct {
},
},
DomainDisk{
- Type: "volume",
+ Type: "volume",
Device: "cdrom",
+ Cache: "none",
+ Io: "native",
Source: &DomainDiskSource{
- Pool: "default",
+ Pool: "default",
Volume: "myvolume",
},
Target: &DomainDiskTarget{
@@ -174,7 +186,7 @@ var domainTestData = []struct {
` </source>`,
` <target dev="vdd" bus="virtio"></target>`,
` </disk>`,
- ` <disk type="volume" device="cdrom">`,
+ ` <disk type="volume" device="cdrom" cache="none" io="native">`,
` <source pool="default" volume="myvolume"></source>`,
` <target dev="vde" bus="virtio"></target>`,
` </disk>`,
@@ -820,6 +832,44 @@ var domainTestData = []struct {
`</domain>`,
},
},
+ {
+ Object: &Domain{
+ Type: "kvm",
+ Name: "test",
+ Devices: &DomainDeviceList{
+ Controllers: []DomainController{
+ DomainController{
+ Type: "usb",
+ Index: &uhciIndex,
+ Model: "piix3-uhci",
+ Address: &DomainAddress{
+ Type: "pci",
+ Domain: &uhciAddr.Domain,
+ Bus: &uhciAddr.Bus,
+ Slot: &uhciAddr.Slot,
+ Function: &uhciAddr.Function,
+ },
+ },
+ DomainController{
+ Type: "usb",
+ Index: nil,
+ Model: "ehci",
+ },
+ },
+ },
+ },
+ Expected: []string{
+ `<domain type="kvm">`,
+ ` <name>test</name>`,
+ ` <devices>`,
+ ` <controller type="usb" index="0" model="piix3-uhci">`,
+ ` <address type="pci" domain="0" bus="0" slot="1" function="2"></address>`,
+ ` </controller>`,
+ ` <controller type="usb" model="ehci"></controller>`,
+ ` </devices>`,
+ `</domain>`,
+ },
+ },
}
func TestDomain(t *testing.T) {
--
2.7.4
7 years, 5 months
[libvirt] Entering freeze for libvirt-3.4.0
by Daniel Veillard
So as planned I tagged the release candidate 1 in git and pushed signed
tarball and rpms to the usual place:
ftp://libvirt.org/libvirt/
Everything seems to work fine for me with RC1 on my limited testing
but as usual please give it some attention to find out issues and check
portability on the various platforms.
If everything woks well, I will push the RC2 on Tuesday and then we can roll
out 3.4.0 and get out of the freeze next Thursday,
but in the meantime, please give it a try !
Thanks,
Daniel
--
Daniel Veillard | Red Hat Developers Tools http://developer.redhat.com/
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
7 years, 5 months
[libvirt] [PATCH] udev: Fix build on older platforms
by Erik Skultety
Caused by commit @d1eea6c1 due to the missing symbol on older platforms.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
Despite falling under build-breaker category, I'd like to get a proper review,
since I'm not really familiar with autoconf and there might be a better fix.
Erik
configure.ac | 2 +-
src/node_device/node_device_udev.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 246f4e077..b78c8b790 100644
--- a/configure.ac
+++ b/configure.ac
@@ -322,7 +322,7 @@ AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
getmntent_r getpwuid_r getrlimit getuid if_indextoname kill mmap \
newlocale posix_fallocate posix_memalign prlimit regexec \
sched_getaffinity setgroups setns setrlimit symlink sysctlbyname \
- getifaddrs sched_setscheduler unshare])
+ getifaddrs sched_setscheduler unshare udev_monitor_set_receive_buffer_size])
dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h regex.h sys/un.h \
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index a69dc1175..01438ea17 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1764,12 +1764,14 @@ static int nodeStateInitialize(bool privileged,
udev_monitor_enable_receiving(priv->udev_monitor);
+#if HAVE_UDEV_MONITOR_SET_RECEIVE_BUFFER_SIZE
/* mimic udevd's behaviour and override the systems rmem_max limit in case
* there's a significant number of device 'add' events
*/
if (geteuid() == 0)
udev_monitor_set_receive_buffer_size(priv->udev_monitor,
128 * 1024 * 1024);
+#endif
/* We register the monitor with the event callback so we are
* notified by udev of device changes before we enumerate existing
--
2.13.0
7 years, 5 months