[libvirt] [PATCH go-xml] Add support for Node Device with basic testing.
by Vladik Romanovsky
---
node_device.go | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++
node_device_test.go | 128 +++++++++++++++++++++++++++++++++++++++
2 files changed, 296 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..d7850e9
--- /dev/null
+++ b/node_device.go
@@ -0,0 +1,168 @@
+/*
+ * 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"
+)
+
+type NodeDevice struct {
+ Name string `xml:"name"`
+ Path string `xml:"path,omitempty"`
+ Parent string `xml:"parent,omitempty"`
+ Driver string `xml:"driver>name,omitempty"`
+ Capability []NodeDeviceCapability `xml:"capability"`
+}
+
+type NodeDeviceCapability struct {
+ Domain int `xml:"domain,omitempty"`
+ Bus int `xml:"bus,omitempty"`
+ Slot int `xml:"slot,omitempty"`
+ Function int `xml:"function,omitempty"`
+ IommuGroup *NodeDeviceIOMMUGroup `xml:"iommuGroup,omitempty"`
+ Numa *NodeDeviceNUMA `xml:"numa,omitempty"`
+ PciExpress *NodeDevicePciExpress `xml:"pci-express,omitempty"`
+ Hardware *NodeDeviceSystemHardware `xml:"hardware"`
+ Firmware *NodeDeviceSystemFirmware `xml:"firmware"`
+ Device int `xml:"device"`
+ Number int `xml:"number"`
+ Class int `xml:"class"`
+ Subclass int `xml:"subclass"`
+ Protocol int `xml:"protocol"`
+ Description string `xml:"description,omitempty"`
+ Interface string `xml:"interface"`
+ Address string `xml:"address"`
+ Link *NodeDeviceNetLink `xml:"link"`
+ Features []NodeDeviceNetOffloadFeatures `xml:"feature,omitempty"`
+ UniqueID int `xml:"unique_id"`
+ Target int `xml:"target"`
+ Lun int `xml:"lun"`
+ Block string `xml:"block"`
+ DriverType string `xml:"drive_type"`
+ Model string `xml:"model"`
+ Serial string `xml:"serial"`
+ Size int `xml:"size"`
+ Host int `xml:"host"`
+ Type string `xml:"type"`
+ Product *NodeDeviceProduct `xml:"product,omitempty"`
+ Vendor *NodeDeviceVendor `xml:"vendor,omitempty"`
+ Capability []NodeDeviceNestedCapabilities `xml:"capability,omitempty"`
+}
+
+type NodeDeviceVendor struct {
+ ID string `xml:"id,attr,omitempty"`
+ Name string `xml:",chardata"`
+}
+type NodeDeviceProduct struct {
+ ID string `xml:"id,attr,omitempty"`
+ Name string `xml:",chardata"`
+}
+
+type NodeDeviceNestedCapabilities struct {
+ Type string `xml:"type,attr"`
+ Address []NodeDevicePCIAddress `xml:"address,omitempty"`
+ MaxCount int `xml:"maxCount,attr,omitempty"`
+ VportsOPS *NodeDeviceSCSIVportsOPS `xml:"vports_ops,omitempty"`
+ FCHost *NodeDeviceSCSIFCHost `xml:"fc_host,omitempty"`
+ MediaAvailable int `xml:"media_available,omitempty"`
+ MediaSize int `xml:"media_size,omitempty"`
+ MediaLable int `xml:"media_label,omitempty"`
+}
+
+type NodeDevicePciExpress struct {
+ Links []NodeDevicePciExpressLink `xml:"link"`
+}
+
+type NodeDevicePciExpressLink 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 NodeDeviceIOMMUGroup struct {
+ Number int `xml:"number,attr"`
+}
+
+type NodeDeviceNUMA struct {
+ Node int `xml:"node,attr"`
+}
+
+type NodeDevicePCIAddress struct {
+ Domain string `xml:"domain,attr"`
+ Bus string `xml:"bus,attr"`
+ Slot string `xml:"slot,attr"`
+ Function string `xml:"function,attr"`
+}
+
+type NodeDeviceSystemHardware struct {
+ Vendor string `xml:"vendor"`
+ Version string `xml:"version"`
+ Serial string `xml:"serial"`
+ UUID string `xml:"uuid"`
+}
+
+type NodeDeviceSystemFirmware struct {
+ Vendor string `xml:"vendor"`
+ Version string `xml:"version"`
+ ReleaseData string `xml:"release_date"`
+}
+
+type NodeDeviceNetOffloadFeatures struct {
+ Name string `xml:"number"`
+}
+
+type NodeDeviceNetLink struct {
+ State string `xml:"state,attr"`
+ Speed string `xml:"speed,attr,omitempty"`
+}
+
+type NetCapability struct {
+ Type string `xml:"type,attr"`
+}
+
+type NodeDeviceSCSIVportsOPS struct {
+ Vports int `xml:"vports,omitempty"`
+ MaxVports int `xml:"maxvports,,omitempty"`
+}
+
+type NodeDeviceSCSIFCHost struct {
+ WWNN string `xml:"wwnn,omitempty"`
+ WWPN string `xml:"wwpn,omitempty"`
+ FabricWWN string `xml:"fabric_wwn,omitempty"`
+}
+
+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..bae15f3
--- /dev/null
+++ b/node_device_test.go
@@ -0,0 +1,128 @@
+/*
+ * 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: []NodeDeviceCapability{
+ NodeDeviceCapability{
+ Domain: 1,
+ Bus: 21,
+ Slot: 10,
+ Function: 50,
+ Product: &NodeDeviceProduct{
+ ID: "0x1528",
+ Name: "Ethernet Controller 10-Gigabit X540-AT2",
+ },
+ Vendor: &NodeDeviceVendor{
+ ID: "0x8086",
+ Name: "Intel Corporation",
+ },
+ IommuGroup: &NodeDeviceIOMMUGroup{
+ Number: 3,
+ },
+ Numa: &NodeDeviceNUMA{
+ Node: 1,
+ },
+ Capability: []NodeDeviceNestedCapabilities{
+ NodeDeviceNestedCapabilities{
+ Type: "virt_functions",
+ Address: []NodeDevicePCIAddress{
+ NodeDevicePCIAddress{
+ Domain: "0x0000",
+ Bus: "0x81",
+ Slot: "0x10",
+ Function: "0x1",
+ },
+ NodeDevicePCIAddress{
+ Domain: "0x0000",
+ Bus: "0x81",
+ Slot: "0x10",
+ Function: "0x3",
+ },
+ },
+ 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'>`,
+ ` <address domain='0x0000' bus='0x81' slot='0x10' function='0x1'/>`,
+ ` <address domain='0x0000' bus='0x81' slot='0x10' function='0x3'/>`,
+ ` </capability>`,
+ ` <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, 6 months
[libvirt] [PATCH go-xml] Add support for domain input address
by zhenwei.pi
---
domain.go | 5 +++--
domain_test.go | 11 ++++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/domain.go b/domain.go
index bf0b851..dcb8f65 100644
--- a/domain.go
+++ b/domain.go
@@ -232,8 +232,9 @@ type DomainChardev struct {
}
type DomainInput struct {
- Type string `xml:"type,attr"`
- Bus string `xml:"bus,attr"`
+ Type string `xml:"type,attr"`
+ Bus string `xml:"bus,attr"`
+ Address *DomainAddress `xml:"address"`
}
type DomainGraphicListener struct {
diff --git a/domain_test.go b/domain_test.go
index 7990627..632b714 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -48,6 +48,8 @@ var balloonAddr = Address{0, 0, 7, 0}
var duplexAddr = Address{0, 0, 8, 0}
var serialPort uint = 0
+var tabletBus uint = 0
+var tabletPort uint = 1
var domainTestData = []struct {
Object *Domain
@@ -230,6 +232,11 @@ var domainTestData = []struct {
DomainInput{
Type: "tablet",
Bus: "usb",
+ Address: &DomainAddress{
+ Type: "usb",
+ Bus: &tabletBus,
+ Port: &tabletPort,
+ },
},
DomainInput{
Type: "keyboard",
@@ -301,7 +308,9 @@ var domainTestData = []struct {
` <serial type="pty">`,
` <target port="0"></target>`,
` </serial>`,
- ` <input type="tablet" bus="usb"></input>`,
+ ` <input type="tablet" bus="usb">`,
+ ` <address type="usb" bus="0" port="1"></address>`,
+ ` </input>`,
` <input type="keyboard" bus="ps2"></input>`,
` <graphics type="vnc"></graphics>`,
` <video>`,
--
2.7.4
7 years, 6 months
[libvirt] [PATCH] virsh: ignore readline -Wstrict-prototypes warning
by Roman Bogorodskiy
When building with clang 4.0.0, virsh build fails like this:
gmake[3]: Entering directory '/usr/home/novel/code/libvirt/tools'
CC virsh-virsh.o
In file included from virsh.c:45:
In file included from /usr/local/include/readline/readline.h:31:
/usr/local/include/readline/rltypedefs.h:35:22: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef int Function () __attribute__ ((deprecated));
^
void
/usr/local/include/readline/rltypedefs.h:36:24: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef void VFunction () __attribute__ ((deprecated));
^
void
/usr/local/include/readline/rltypedefs.h:37:26: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef char *CPFunction () __attribute__ ((deprecated));
^
void
/usr/local/include/readline/rltypedefs.h:38:28: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
typedef char **CPPFunction () __attribute__ ((deprecated));
^
void
In file included from virsh.c:45:
/usr/local/include/readline/readline.h:385:23: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
extern int rl_message ();
^
void
5 errors generated.
gmake[3]: *** [Makefile:2823: virsh-virsh.o] Error 1
Fix that by adding VIR_WARNINGS_NO_STRICT_PROTOTYPES macro that uses
"GCC diagnostic push" to ignore -Wstrict-prototypes and wrapping
readline includes with it and VIR_WARNINGS_RESET.
Bug report on the readline mailing list:
http://lists.gnu.org/archive/html/bug-readline/2017-05/msg00004.html
---
src/internal.h | 4 ++++
tools/virsh.c | 2 ++
tools/virt-admin.c | 2 ++
3 files changed, 8 insertions(+)
diff --git a/src/internal.h b/src/internal.h
index 03a973ccd..57b6da7ff 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -266,6 +266,10 @@
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+# define VIR_WARNINGS_NO_STRICT_PROTOTYPES \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wstrict-prototypes\"")
+
# if HAVE_SUGGEST_ATTRIBUTE_FORMAT
# define VIR_WARNINGS_NO_PRINTF \
_Pragma ("GCC diagnostic push") \
diff --git a/tools/virsh.c b/tools/virsh.c
index 1f5c2b11c..1a28a2620 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -41,8 +41,10 @@
#include <signal.h>
#if WITH_READLINE
+VIR_WARNINGS_NO_STRICT_PROTOTYPES
# include <readline/readline.h>
# include <readline/history.h>
+VIR_WARNINGS_RESET
#endif
#include "internal.h"
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index 0fa1c000c..7ad4c29e1 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -27,8 +27,10 @@
#include <getopt.h>
#if WITH_READLINE
+VIR_WARNINGS_NO_STRICT_PROTOTYPES
# include <readline/readline.h>
# include <readline/history.h>
+VIR_WARNINGS_RESET
#endif
#include "internal.h"
--
2.13.0
7 years, 6 months
[libvirt] [PATCH] qemu: Don't special case mdevs when assigning PCI addresses
by Andrea Bolognani
We can treat mdevs the same as all other PCI hostdevs
and figure out whether they are PCI Express or legacy PCI
by checking the size of their config space.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_domain_address.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 2106b34..3277d18 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -645,9 +645,6 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
return pcieFlags;
}
- if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV)
- return pcieFlags;
-
if (!(pciDev = virPCIDeviceNew(hostAddr->domain,
hostAddr->bus,
hostAddr->slot,
--
2.7.4
7 years, 6 months
[libvirt] [PATCH v2] daemon: Don't initialize SASL context if not necessary
by Peter Krempa
SASL context would be initialized even if the corresponding TCP or TLS
sockets are not enabled.
fe772f24a68 attempted to fix the symptom by commenting out the settings,
but that did not fix the root cause. 3c647ee4bbb later reverted those
changes so that the more secure algorithm is used.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1450095
---
v2:
Fix the message also if SASL authentication and the TCP/TLS sockets are
explicitly enabled in config bug --listen is not specified.
daemon/libvirtd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 891238bcb..bac4bc1b6 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -613,11 +613,11 @@ daemonSetupNetworking(virNetServerPtr srv,
#if WITH_SASL
if (config->auth_unix_rw == REMOTE_AUTH_SASL ||
- config->auth_unix_ro == REMOTE_AUTH_SASL ||
+ (sock_path_ro && config->auth_unix_ro == REMOTE_AUTH_SASL) ||
# if WITH_GNUTLS
- config->auth_tls == REMOTE_AUTH_SASL ||
+ (ipsock && config->listen_tls && config->auth_tls == REMOTE_AUTH_SASL) ||
# endif
- config->auth_tcp == REMOTE_AUTH_SASL) {
+ (ipsock && config->listen_tcp && config->auth_tcp == REMOTE_AUTH_SASL)) {
saslCtxt = virNetSASLContextNewServer(
(const char *const*)config->sasl_allowed_username_list);
if (!saslCtxt)
--
2.12.2
7 years, 6 months
[libvirt] [PATCH] daemon: Don't initialize SASL context if not necessary
by Peter Krempa
SASL context would be initialized even if the corresponding TCP or TLS
sockets are not enabled.
fe772f24a68 attempted to fix the symptom by commenting out the settings,
but that did not fix the root cause. 3c647ee4bbb later reverted those
changes so that the more secure algorithm is used.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1450095
---
daemon/libvirtd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 891238bcb..4a242e3e5 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -613,11 +613,11 @@ daemonSetupNetworking(virNetServerPtr srv,
#if WITH_SASL
if (config->auth_unix_rw == REMOTE_AUTH_SASL ||
- config->auth_unix_ro == REMOTE_AUTH_SASL ||
+ (sock_path_ro && config->auth_unix_ro == REMOTE_AUTH_SASL) ||
# if WITH_GNUTLS
- config->auth_tls == REMOTE_AUTH_SASL ||
+ (config->listen_tls && config->auth_tls == REMOTE_AUTH_SASL) ||
# endif
- config->auth_tcp == REMOTE_AUTH_SASL) {
+ (config->listen_tcp && config->auth_tcp == REMOTE_AUTH_SASL)) {
saslCtxt = virNetSASLContextNewServer(
(const char *const*)config->sasl_allowed_username_list);
if (!saslCtxt)
--
2.12.2
7 years, 6 months
[libvirt] [V3 PATCH] RFC: Reimplement cache allocation for a VM
by Eli Qiao
From: Eli Qiao <liyong.qiao(a)intel.com>
This is a RFC patch for the reimplement of `support cache tune(CAT) in
libvirt`[1].
This patch defines some structs to represent data struct in linux
resctrl fs which will be used later to do cache allocation.
The patch expose a private interface `virResctrlFreeSchemata`, which
will be used to query the cache allocation on the host.
Also added unit test cases to test this interface can works well.
There are already patch sets[2] to address it, and functional
works, but people doesn't like it cause it has global variable, and
missing unit test case for new added capabilites, etc.
Martin has proposed a test infra to do vircaps2xmltest, and I extened it
on top of it to extend resctrl control[3], this is kinds of new desiged
apart from [2], so I propose this RFC patch to do some rework on it.
[1] https://www.redhat.com/archives/libvir-list/2017-January/msg00683.html
[2] https://www.redhat.com/archives/libvir-list/2017-March/msg00181.html
[3] https://www.redhat.com/archives/libvir-list/2017-April/msg00516.html
---
include/libvirt/virterror.h | 1 +
src/Makefile.am | 1 +
src/libvirt_private.syms | 7 +
src/util/virerror.c | 1 +
src/util/virresctrl.c | 390 ++++++++++++++++++++++++++++++
src/util/virresctrl.h | 72 ++++++
tests/Makefile.am | 8 +-
tests/virresctrldata/L3-free.schemata | 1 +
tests/virresctrldata/L3CODE-free.schemata | 1 +
tests/virresctrldata/L3DATA-free.schemata | 1 +
tests/virresctrldata/linux-resctrl | 1 +
tests/virresctrldata/linux-resctrl-cdp | 1 +
tests/virresctrltest.c | 119 +++++++++
13 files changed, 603 insertions(+), 1 deletion(-)
create mode 100644 src/util/virresctrl.c
create mode 100644 src/util/virresctrl.h
create mode 100644 tests/virresctrldata/L3-free.schemata
create mode 100644 tests/virresctrldata/L3CODE-free.schemata
create mode 100644 tests/virresctrldata/L3DATA-free.schemata
create mode 120000 tests/virresctrldata/linux-resctrl
create mode 120000 tests/virresctrldata/linux-resctrl-cdp
create mode 100644 tests/virresctrltest.c
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 2efee8f..4bc0c74 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -132,6 +132,7 @@ typedef enum {
VIR_FROM_PERF = 65, /* Error from perf */
VIR_FROM_LIBSSH = 66, /* Error from libssh connection transport */
+ VIR_FROM_RESCTRL = 67, /* Error from resctrl */
# ifdef VIR_ENUM_SENTINELS
VIR_ERR_DOMAIN_LAST
diff --git a/src/Makefile.am b/src/Makefile.am
index 0b7cfc8..08ad5b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -167,6 +167,7 @@ UTIL_SOURCES = \
util/virprocess.c util/virprocess.h \
util/virqemu.c util/virqemu.h \
util/virrandom.h util/virrandom.c \
+ util/virresctrl.h util/virresctrl.c \
util/virrotatingfile.h util/virrotatingfile.c \
util/virscsi.c util/virscsi.h \
util/virscsihost.c util/virscsihost.h \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 429b095..cdd3467 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2424,6 +2424,13 @@ virRandomGenerateWWN;
virRandomInt;
+# util/virresctrl.h
+virResctrlBitmap2String;
+virResctrlFreeSchemata;
+virResctrlGetFreeCache;
+virResctrlTypeToString;
+
+
# util/virrotatingfile.h
virRotatingFileReaderConsume;
virRotatingFileReaderFree;
diff --git a/src/util/virerror.c b/src/util/virerror.c
index ef17fb5..02fabcc 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -139,6 +139,7 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST,
"Perf", /* 65 */
"Libssh transport layer",
+ "Resource Control",
)
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
new file mode 100644
index 0000000..d3822ed
--- /dev/null
+++ b/src/util/virresctrl.c
@@ -0,0 +1,390 @@
+/*
+ * virresctrl.c: methods for managing resource control
+ *
+ * Copyright (C) 2017 Intel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Eli Qiao <liyong.qiao(a)intel.com>
+ */
+
+#include <config.h>
+#include <fcntl.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "virresctrl.h"
+#include "virerror.h"
+#include "virlog.h"
+#include "viralloc.h"
+#include "virstring.h"
+#include "virfile.h"
+
+VIR_LOG_INIT("util.resctrl");
+
+#define VIR_FROM_THIS VIR_FROM_RESCTRL
+#define SYSFS_RESCTRL_PATH "/sys/fs/resctrl"
+#define MAX_CBM_LEN 20
+
+VIR_ENUM_IMPL(virResctrl, VIR_RESCTRL_TYPE_LAST,
+ "L3",
+ "L3CODE",
+ "L3DATA")
+
+/**
+ * a virResctrlGroup represents a resource control group, it's a directory
+ * under /sys/fs/resctrl.
+ * e.g. /sys/fs/resctrl/CG1
+ * |-- cpus
+ * |-- schemata
+ * `-- tasks
+ * # cat schemata
+ * L3DATA:0=fffff;1=fffff
+ * L3CODE:0=fffff;1=fffff
+ *
+ * Besides, it can also represent the default resource control group of the
+ * host.
+ */
+
+typedef struct _virResctrlGroup virResctrlGroup;
+typedef virResctrlGroup *virResctrlGroupPtr;
+struct _virResctrlGroup {
+ char *name; /* resource group name, NULL for default host group */
+ size_t n_tasks; /* number of tasks assigned to the resource group */
+ char **tasks; /* task id list */
+
+ virResctrlSchemataPtr schemata[VIR_RESCTRL_TYPE_LAST]; /* Array for schemata */
+};
+
+/* All resource control groups on this host, including default resource group */
+typedef struct _virResctrlHost virResctrlHost;
+typedef virResctrlHost *virResctrlHostPtr;
+struct _virResctrlHost {
+ size_t n_groups; /* number of resource control group */
+ virResctrlGroupPtr *groups; /* list of resource control group */
+};
+
+void
+virResctrlFreeSchemata(virResctrlSchemataPtr ptr)
+{
+ size_t i;
+
+ if (!ptr)
+ return;
+ for (i = 0; i < ptr->n_masks; i++) {
+ virBitmapFree(ptr->masks[i]->mask);
+ VIR_FREE(ptr->masks[i]);
+ }
+
+ VIR_FREE(ptr->masks);
+ VIR_FREE(ptr);
+ ptr = NULL;
+}
+
+static void
+virResctrlFreeGroup(virResctrlGroupPtr ptr)
+{
+ size_t i;
+
+ if (!ptr)
+ return;
+
+
+ virStringListFree(ptr->tasks);
+ VIR_FREE(ptr->name);
+
+ for (i = 0; i < VIR_RESCTRL_TYPE_LAST; i++)
+ virResctrlFreeSchemata(ptr->schemata[i]);
+
+ VIR_FREE(ptr);
+ ptr = NULL;
+}
+
+/* Return specify type of schemata string from schematalval.
+ e.g., 0=f;1=f */
+static int
+virResctrlGetSchemataString(virResctrlType type,
+ const char *schemataval,
+ char **schematastr)
+{
+ int rc = -1;
+ char *prefix = NULL;
+ char **lines = NULL;
+
+ if (virAsprintf(&prefix,
+ "%s:",
+ virResctrlTypeToString(type)) < 0)
+ return -1;
+
+ lines = virStringSplit(schemataval, "\n", 0);
+
+ if (VIR_STRDUP(*schematastr,
+ virStringListGetFirstWithPrefix(lines, prefix)) < 0)
+ goto cleanup;
+
+ if (*schematastr == NULL)
+ rc = -1;
+ else
+ rc = 0;
+
+ cleanup:
+ VIR_FREE(prefix);
+ virStringListFree(lines);
+ return rc;
+}
+
+static
+virBitmapPtr virResctrlMask2Bitmap(const char *mask)
+{
+ virBitmapPtr bitmap;
+ unsigned int tmp;
+ size_t i;
+
+ if (virStrToLong_ui(mask, NULL, 16, &tmp) < 0)
+ return NULL;
+
+ bitmap = virBitmapNewQuiet(MAX_CBM_LEN);
+
+ for (i = 0; i < MAX_CBM_LEN; i++) {
+ if (((tmp & 0x1) == 0x1) &&
+ (virBitmapSetBit(bitmap, i) < 0))
+ goto error;
+ tmp = tmp >> 1;
+ }
+
+ return bitmap;
+
+ error:
+ virBitmapFree(bitmap);
+ return NULL;
+}
+
+char *virResctrlBitmap2String(virBitmapPtr bitmap)
+{
+ char *tmp;
+ char *ret = NULL;
+ char *p;
+ tmp = virBitmapString(bitmap);
+ // skip "0x"
+ p = tmp + 2;
+
+ // find first non-0 position
+ while (*++p == '0');
+
+ if (VIR_STRDUP(ret, p) < 0)
+ ret = NULL;
+
+ VIR_FREE(tmp);
+ return ret;
+}
+
+static int
+virResctrlParseSchemata(const char* schemata_str,
+ virResctrlSchemataPtr schemata)
+{
+ VIR_DEBUG("schemata_str=%s, schemata=%p", schemata_str, schemata);
+
+ int ret = -1;
+ size_t i;
+ virResctrlMaskPtr mask;
+ char **schemata_list;
+ char *mask_str;
+
+ /* parse 0=fffff;1=f */
+ schemata_list = virStringSplit(schemata_str, ";", 0);
+
+ if (!schemata_list)
+ goto cleanup;
+
+ for (i = 0; schemata_list[i] != NULL; i++) {
+ /* parse 0=fffff */
+ mask_str = strchr(schemata_list[i], '=');
+
+ if (!mask_str)
+ goto cleanup;
+
+ if (VIR_ALLOC(mask) < 0)
+ goto cleanup;
+
+ mask->cache_id = i;
+ mask->mask = virResctrlMask2Bitmap(mask_str + 1);
+
+ if (VIR_APPEND_ELEMENT(schemata->masks,
+ schemata->n_masks,
+ mask) < 0) {
+ VIR_FREE(mask);
+ goto cleanup;
+ }
+
+ }
+ ret = 0;
+
+ cleanup:
+ virStringListFree(schemata_list);
+ return ret;
+}
+
+static int
+virResctrlLoadGroup(const char *name,
+ virResctrlHostPtr host)
+{
+ VIR_DEBUG("name=%s, host=%p\n", name, host);
+
+ int ret = -1;
+ char *schemataval = NULL;
+ char *schemata_str = NULL;
+ virResctrlType i;
+ int rv;
+ virResctrlGroupPtr grp;
+ virResctrlSchemataPtr schemata;
+
+ rv = virFileReadValueString(&schemataval,
+ SYSFS_RESCTRL_PATH "/%s/schemata",
+ name ? name : "");
+
+ if (rv < 0)
+ return -1;
+
+ if (VIR_ALLOC(grp) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(grp->name, name) < 0)
+ goto cleanup;
+
+ for (i = 0; i < VIR_RESCTRL_TYPE_LAST; i++) {
+ rv = virResctrlGetSchemataString(i, schemataval, &schemata_str);
+
+ if (rv < 0)
+ continue;
+
+ if (VIR_ALLOC(schemata) < 0)
+ goto cleanup;
+
+ schemata->type = i;
+
+ if (virResctrlParseSchemata(schemata_str, schemata) < 0) {
+ VIR_FREE(schemata);
+ VIR_FREE(schemata_str);
+ goto cleanup;
+ }
+
+ grp->schemata[i] = schemata;
+ VIR_FREE(schemata_str);
+ }
+
+ if (VIR_APPEND_ELEMENT(host->groups,
+ host->n_groups,
+ grp) < 0) {
+ virResctrlFreeGroup(grp);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(schemataval);
+ return ret;
+}
+
+static int
+virResctrlLoadHost(virResctrlHostPtr host)
+{
+ int ret = -1;
+ int rv = -1;
+ DIR *dirp = NULL;
+ char *path = NULL;
+ struct dirent *ent;
+
+ VIR_DEBUG("host=%p\n", host);
+
+ rv = virDirOpenIfExists(&dirp, SYSFS_RESCTRL_PATH);
+
+ if (rv < 0)
+ goto cleanup;
+
+ /* load default group first */
+ if (virResctrlLoadGroup(NULL, host) < 0)
+ goto cleanup;
+
+ while ((rv = virDirRead(dirp, &ent, path)) > 0) {
+ /* resctrl is not hierarchical, only read directory under
+ /sys/fs/resctrl */
+ if ((ent->d_type != DT_DIR) || STREQ(ent->d_name, "info"))
+ continue;
+
+ if (virResctrlLoadGroup(ent->d_name, host) < 0)
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ virDirClose(&dirp);
+ return ret;
+}
+
+static void
+virResctrlRefreshHost(virResctrlHostPtr host)
+{
+ virResctrlGroupPtr default_grp = NULL;
+ virResctrlGroupPtr grp = NULL;
+ virResctrlSchemataPtr schemata = NULL;
+ size_t i, j;
+ virResctrlType t;
+
+ default_grp = host->groups[0];
+
+ /* Loop each other resource group except default group */
+ for (i = 1; i < host->n_groups; i++) {
+ grp = host->groups[i];
+ for (t = 0; t < VIR_RESCTRL_TYPE_LAST; t++) {
+ schemata = grp->schemata[t];
+ if (schemata != NULL) {
+ for (j = 0; j < schemata->n_masks; j++)
+ virBitmapSubtract(default_grp->schemata[t]->masks[j]->mask,
+ schemata->masks[j]->mask);
+ }
+ }
+ }
+}
+
+virResctrlSchemataPtr
+virResctrlGetFreeCache(virResctrlType type)
+{
+ VIR_DEBUG("type=%d", type);
+ virResctrlHostPtr host = NULL;
+ virResctrlSchemataPtr schemata = NULL;
+ size_t i;
+
+ if (VIR_ALLOC(host) < 0)
+ return NULL;
+
+ if (virResctrlLoadHost(host) < 0)
+ return NULL;
+
+ /* default group come the first one */
+ virResctrlRefreshHost(host);
+
+ schemata = host->groups[0]->schemata[type];
+
+ for (i = 1; i < host->n_groups; i++)
+ virResctrlFreeGroup(host->groups[i]);
+ VIR_FREE(host->groups);
+ host = NULL;
+
+ return schemata;
+}
diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
new file mode 100644
index 0000000..7c9a1b7
--- /dev/null
+++ b/src/util/virresctrl.h
@@ -0,0 +1,72 @@
+/*
+ * virresctrl.h: header for managing resctrl control
+ *
+ * Copyright (C) 2017 Intel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Eli Qiao <liyong.qiao(a)intel.com>
+ */
+
+#ifndef __VIR_RESCTRL_H__
+# define __VIR_RESCTRL_H__
+
+#include "virutil.h"
+#include "virbitmap.h"
+
+typedef enum {
+ VIR_RESCTRL_TYPE_L3,
+ VIR_RESCTRL_TYPE_L3_CODE,
+ VIR_RESCTRL_TYPE_L3_DATA,
+
+ VIR_RESCTRL_TYPE_LAST
+} virResctrlType;
+
+VIR_ENUM_DECL(virResctrl);
+
+/*
+ * a virResctrlMask represents one of mask object in a
+ * resource control group.
+ * e.g., 0=f
+ */
+typedef struct _virResctrlMask virResctrlMask;
+typedef virResctrlMask *virResctrlMaskPtr;
+struct _virResctrlMask {
+ unsigned int cache_id; /* cache resource id */
+ virBitmapPtr mask; /* the cbm mask */
+};
+
+/*
+ * a virResctrlSchemata represents schemata objects of specific type of
+ * resource in a resource control group.
+ * eg: L3:0=f,1=ff
+ */
+typedef struct _virResctrlSchemata virResctrlSchemata;
+typedef virResctrlSchemata *virResctrlSchemataPtr;
+struct _virResctrlSchemata {
+ virResctrlType type; /* resource control type, e.g., L3 */
+ size_t n_masks; /* number of masks */
+ virResctrlMaskPtr *masks; /* list of mask */
+};
+
+/* Get free cache of the host, result saved in schemata */
+virResctrlSchemataPtr virResctrlGetFreeCache(virResctrlType type);
+
+/* Get mask string from Bitmap */
+char *virResctrlBitmap2String(virBitmapPtr bitmap);
+
+void virResctrlFreeSchemata(virResctrlSchemataPtr ptr);
+#endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7673329..0dcef4f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -229,6 +229,7 @@ if WITH_LINUX
test_programs += fchosttest
test_programs += scsihosttest
test_programs += vircaps2xmltest
+test_programs += virresctrltest
test_libraries += virusbmock.la \
virnetdevbandwidthmock.la \
virnumamock.la \
@@ -1156,8 +1157,13 @@ virnumamock_la_CFLAGS = $(AM_CFLAGS)
virnumamock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
virnumamock_la_LIBADD = $(MOCKLIBS_LIBS)
+virresctrltest_SOURCES = \
+ virresctrltest.c testutils.h testutils.c virfilewrapper.h virfilewrapper.c
+virresctrltest_LDADD = $(LDADDS)
+
else ! WITH_LINUX
-EXTRA_DIST += vircaps2xmltest.c virnumamock.c virfilewrapper.c virfilewrapper.h
+EXTRA_DIST += vircaps2xmltest.c virnumamock.c virfilewrapper.c \
+ virfilewrapper.h virresctrltest.c
endif ! WITH_LINUX
if WITH_NSS
diff --git a/tests/virresctrldata/L3-free.schemata b/tests/virresctrldata/L3-free.schemata
new file mode 100644
index 0000000..9b47d25
--- /dev/null
+++ b/tests/virresctrldata/L3-free.schemata
@@ -0,0 +1 @@
+L3:0=1ffff;1=1ffff
diff --git a/tests/virresctrldata/L3CODE-free.schemata b/tests/virresctrldata/L3CODE-free.schemata
new file mode 100644
index 0000000..7039c45
--- /dev/null
+++ b/tests/virresctrldata/L3CODE-free.schemata
@@ -0,0 +1 @@
+L3CODE:0=cffff;1=cffff
diff --git a/tests/virresctrldata/L3DATA-free.schemata b/tests/virresctrldata/L3DATA-free.schemata
new file mode 100644
index 0000000..30f1cbd
--- /dev/null
+++ b/tests/virresctrldata/L3DATA-free.schemata
@@ -0,0 +1 @@
+L3DATA:0=3ffff;1=3ffff
diff --git a/tests/virresctrldata/linux-resctrl b/tests/virresctrldata/linux-resctrl
new file mode 120000
index 0000000..069dfb2
--- /dev/null
+++ b/tests/virresctrldata/linux-resctrl
@@ -0,0 +1 @@
+../vircaps2xmldata/linux-resctrl
\ No newline at end of file
diff --git a/tests/virresctrldata/linux-resctrl-cdp b/tests/virresctrldata/linux-resctrl-cdp
new file mode 120000
index 0000000..c5a973f
--- /dev/null
+++ b/tests/virresctrldata/linux-resctrl-cdp
@@ -0,0 +1 @@
+../vircaps2xmldata/linux-resctrl-cdp
\ No newline at end of file
diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c
new file mode 100644
index 0000000..4eaa925
--- /dev/null
+++ b/tests/virresctrltest.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) Intel, Inc. 2017
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Eli Qiao <liyong.qiao(a)intel.com>
+ */
+
+#include <config.h>
+#include <stdlib.h>
+
+#include "testutils.h"
+#include "virbitmap.h"
+#include "virfilewrapper.h"
+#include "virresctrl.h"
+
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+struct virResctrlData {
+ const char *filename;
+ virResctrlType type;
+};
+
+static void
+GetSchemataStr(virResctrlSchemataPtr schemata, char **str)
+{
+ size_t i;
+
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ virBufferAsprintf(&buf, "%s:%u=%s",
+ virResctrlTypeToString(schemata->type),
+ schemata->masks[0]->cache_id,
+ virResctrlBitmap2String(schemata->masks[0]->mask));
+
+ for (i = 1; i < schemata->n_masks; i ++)
+ virBufferAsprintf(&buf, ";%u=%s",
+ schemata->masks[i]->cache_id,
+ virResctrlBitmap2String(schemata->masks[i]->mask));
+
+ *str = virBufferContentAndReset(&buf);
+}
+
+static int
+test_virResctrl(const void *opaque)
+{
+ struct virResctrlData *data = (struct virResctrlData *) opaque;
+ char *dir = NULL;
+ char *resctrl = NULL;
+ int ret = -1;
+ virResctrlSchemataPtr schemata = NULL;
+ char *schemata_str = NULL;
+ char *schemata_file;
+
+ if (virAsprintf(&resctrl, "%s/virresctrldata/linux-%s/resctrl",
+ abs_srcdir, data->filename) < 0)
+ goto cleanup;
+
+ if (virAsprintf(&schemata_file, "%s/virresctrldata/%s-free.schemata",
+ abs_srcdir, virResctrlTypeToString(data->type)) < 0)
+ goto cleanup;
+
+ if (virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl) < 0)
+ goto cleanup;
+
+ if ((schemata = virResctrlGetFreeCache(data->type)) == NULL)
+ goto cleanup;
+
+ virFileWrapperClearPrefixes();
+
+ GetSchemataStr(schemata, &schemata_str);
+
+ if (virTestCompareToFile(schemata_str, schemata_file) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(dir);
+ VIR_FREE(resctrl);
+ //VIR_FREE(schemata_str);
+ virResctrlFreeSchemata(schemata);
+ return ret;
+}
+
+static int
+mymain(void)
+{
+ int ret = 0;
+
+#define DO_TEST_FULL(filename, type) \
+ do { \
+ struct virResctrlData data = {filename, \
+ type}; \
+ if (virTestRun(filename, test_virResctrl, &data) < 0) \
+ ret = -1; \
+ } while (0)
+
+ DO_TEST_FULL("resctrl", VIR_RESCTRL_TYPE_L3);
+ DO_TEST_FULL("resctrl-cdp", VIR_RESCTRL_TYPE_L3_CODE);
+ DO_TEST_FULL("resctrl-cdp", VIR_RESCTRL_TYPE_L3_DATA);
+
+ return ret;
+}
+
+VIR_TEST_MAIN(mymain)
--
1.9.1
7 years, 6 months
[libvirt] [PATCH] util: removing dead code inside virstoragefile.
by Julio Faracco
The host address or the socket path have already been checked at the begining
of the function virStorageSourceParseNBDColonString(). So, when the parameter
is not a unix socket, there is no reason to check the address again because
if it does not exists, the logic will fail in the first IF conditional.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/util/virstoragefile.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index b43acf6..6d8ada9 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2635,13 +2635,6 @@ virStorageSourceParseNBDColonString(const char *nbdstr,
goto cleanup;
} else {
- if (!backing[1]) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("missing host name in nbd string '%s'"),
- nbdstr);
- goto cleanup;
- }
-
if (VIR_STRDUP(src->hosts->name, backing[1]) < 0)
goto cleanup;
--
2.7.4
7 years, 6 months
[libvirt] [PATCH] util: fixing wrong comparison inside virStoragePermsCopy().
by Julio Faracco
VIR_STRDUP returns -1 if the string copy was not successful. So, the current
comparison/logic is throwing an error when VIR_STRDUP() returns 1. Only when
source is NULL, it is considering as a success which is not right.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/util/virstoragefile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 6d8ada9..e82a7fb 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1974,7 +1974,7 @@ virStoragePermsCopy(const virStoragePerms *src)
ret->uid = src->uid;
ret->gid = src->gid;
- if (VIR_STRDUP(ret->label, src->label))
+ if (VIR_STRDUP(ret->label, src->label) < 0)
goto error;
return ret;
--
2.7.4
7 years, 6 months
[libvirt] [PATCH] Post-release version bump to 3.5.0
by Peter Krempa
---
Pushed as trivial.
configure.ac | 2 +-
docs/news.xml | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 246f4e077..1af5538ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library. If not, see
dnl <http://www.gnu.org/licenses/>.
-AC_INIT([libvirt], [3.4.0], [libvir-list(a)redhat.com], [], [http://libvirt.org])
+AC_INIT([libvirt], [3.5.0], [libvir-list(a)redhat.com], [], [http://libvirt.org])
AC_CONFIG_SRCDIR([src/libvirt.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
diff --git a/docs/news.xml b/docs/news.xml
index 25316fc18..b5ae53760 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -33,6 +33,14 @@
-->
<libvirt>
+ <release version="v3.5.0" date="unreleased">
+ <section title="New features">
+ </section>
+ <section title="Improvements">
+ </section>
+ <section title="Bug fixes">
+ </section>
+ </release>
<release version="v3.4.0" date="2017-06-02">
<section title="New features">
<change>
--
2.12.2
7 years, 6 months