[libvirt] [PATCH 00/11] Adjust build/start format checking for fs, disk, and logical backends
by John Ferlan
Two of these patches (2 and 10) are followups to no-overwrite patches
previously posted (I left links in the patches for reference).
Essentially this series works to unify the probing code from the file
system backend using blkid and the parted format reading code from the
disk backend in one common set of functions.
In doing so, the disk backend will now pick up the ability to use the
blkid 'partitions' APIs in order to "probe" the target device for a
valid/known partition format type. Additionally, the file system
probe will pick up a fallback to the parted mechanism from the disk
backend if the 'blkid' APIs are not built into the system.
A few extra bells/whistles were added for fs pool startup to ensure that
the format in the startup XML matches the format on the target disk,
which is essentially the mechanism the disk backend used (although it
was slightly broken).
Then in order to really pile on, the overwrite logic was added to the
logical pool which didn't have any such checking (both build and start).
Testing was done locally using an iSCSI device and laying down different
formats and seeing what would happen on various usages of the format
(with --overwrite and --no-overwrite).
John Ferlan (11):
storage: Introduce virStorageBackendDeviceProbeEmpty
storage: Fix implementation of no-overwrite for file system backend
storage: Add partition type checks for BLKID probing
storage: Add writelabel bool for virStorageBackendDeviceProbe
storage: For FS pool check for properly formatted target volume
storage: Move and rename disk backend label checking
storage: Adjust disk label found to match labels
storage: Clean up logical pool devices on build failure
storage: Extract logical device initialize into a helper
storage: Add overwrite flag checking for logical pool
storage: Validate the device formats at logical startup
src/libvirt_private.syms | 1 +
src/storage/storage_backend.c | 396 ++++++++++++++++++++++++++++++++++
src/storage/storage_backend.h | 4 +
src/storage/storage_backend_disk.c | 150 ++-----------
src/storage/storage_backend_fs.c | 118 ++--------
src/storage/storage_backend_fs.h | 5 -
src/storage/storage_backend_logical.c | 180 ++++++++++------
tools/virsh-pool.c | 2 +-
tools/virsh.pod | 42 ++--
9 files changed, 585 insertions(+), 313 deletions(-)
--
2.7.4
7 years, 10 months
[libvirt] [PATCH v2] libxl: fix usb inputs loop error
by Cédric Bosdonnat
List indexes where mixed up in the code looping over the USB
input devices.
---
* v2: Increment nusbdevice if LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST is
not defined.
src/libxl/libxl_conf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index ac83b51c7..a24f9e052 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -479,7 +479,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
if (VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) < 0)
return -1;
#else
- if (i > 1) {
+ nusbdevice++;
+ if (nusbdevice > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("libxenlight supports only one input device"));
return -1;
@@ -487,7 +488,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
#endif
#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
- usbdevice = &b_info->u.hvm.usbdevice_list[i];
+ usbdevice = &b_info->u.hvm.usbdevice_list[nusbdevice - 1];
#else
usbdevice = &b_info->u.hvm.usbdevice;
#endif
--
2.11.0
7 years, 10 months
[libvirt] [PATCH] Extend l3 cache to nodeinfo
by Eli Qiao
This patch extends l3 cache infomation to nodeinfo output.
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
---
include/libvirt/libvirt-host.h | 1 +
src/nodeinfo.c | 3 ++-
src/remote/remote_protocol.x | 1 +
src/test/test_driver.c | 1 +
src/util/virhostcpu.c | 29 +++++++++++++++++++++++++----
src/util/virhostcpu.h | 3 ++-
src/util/virhostcpupriv.h | 3 ++-
tests/virhostcputest.c | 3 ++-
tools/virsh-host.c | 1 +
9 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index 07b5d15..ba926df 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -167,6 +167,7 @@ struct _virNodeInfo {
processors in case of unusual NUMA topology*/
unsigned int threads; /* number of threads per core, 1 in case of
unusual numa topology */
+ unsigned int l3_cache; /* l3 cache in kilobytes */
};
/**
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index f2ded02..f54972b 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -152,7 +152,8 @@ nodeGetInfo(virNodeInfoPtr nodeinfo)
if (virHostCPUGetInfo(hostarch,
&nodeinfo->cpus, &nodeinfo->mhz,
&nodeinfo->nodes, &nodeinfo->sockets,
- &nodeinfo->cores, &nodeinfo->threads) < 0)
+ &nodeinfo->cores, &nodeinfo->threads,
+ &nodeinfo->l3_cache) < 0)
return -1;
return 0;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index b846ef2..6a16b4e 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -489,6 +489,7 @@ struct remote_node_get_info_ret { /* insert@1 */
int sockets;
int cores;
int threads;
+ int l3_cache;
};
struct remote_connect_get_capabilities_ret {
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index de92a01..b49c07b 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -138,6 +138,7 @@ static const virNodeInfo defaultNodeInfo = {
2,
2,
2,
+ 4096,
};
static void
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index f29f312..698813b 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -530,7 +530,8 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
unsigned int *nodes,
unsigned int *sockets,
unsigned int *cores,
- unsigned int *threads)
+ unsigned int *threads,
+ unsigned int *l3_cache)
{
virBitmapPtr present_cpus_map = NULL;
virBitmapPtr online_cpus_map = NULL;
@@ -546,7 +547,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
int direrr;
*mhz = 0;
- *cpus = *nodes = *sockets = *cores = *threads = 0;
+ *cpus = *nodes = *sockets = *cores = *threads = *l3_cache = 0;
/* Start with parsing CPU clock speed from /proc/cpuinfo */
while (fgets(line, sizeof(line), cpuinfo) != NULL) {
@@ -571,6 +572,24 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
(*p == '\0' || *p == '.' || c_isspace(*p)))
*mhz = ui;
}
+ if (STRPREFIX(buf, "cache size")) {
+ char *p;
+ unsigned int ui;
+ buf += 10;
+
+ while (*buf && c_isspace(*buf))
+ buf++;
+
+ if (*buf != ':' || !buf[1]) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("parsing cache size from cpuinfo"));
+ goto cleanup;
+ }
+
+ if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 &&
+ *(p+1)=='K' && *(p+2)=='B')
+ *l3_cache = ui;
+ }
} else if (ARCH_IS_PPC(arch)) {
char *buf = line;
if (STRPREFIX(buf, "clock")) {
@@ -960,7 +979,8 @@ virHostCPUGetInfo(virArch hostarch ATTRIBUTE_UNUSED,
unsigned int *nodes ATTRIBUTE_UNUSED,
unsigned int *sockets ATTRIBUTE_UNUSED,
unsigned int *cores ATTRIBUTE_UNUSED,
- unsigned int *threads ATTRIBUTE_UNUSED)
+ unsigned int *threads ATTRIBUTE_UNUSED,
+ unsigned int *l3_cache ATTRIBUTE_UNUSED)
{
#ifdef __linux__
int ret = -1;
@@ -974,7 +994,8 @@ virHostCPUGetInfo(virArch hostarch ATTRIBUTE_UNUSED,
ret = virHostCPUGetInfoPopulateLinux(cpuinfo, hostarch,
cpus, mhz, nodes,
- sockets, cores, threads);
+ sockets, cores, threads,
+ l3_cache);
if (ret < 0)
goto cleanup;
diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h
index 39f7cf8..fc579fe 100644
--- a/src/util/virhostcpu.h
+++ b/src/util/virhostcpu.h
@@ -50,7 +50,8 @@ int virHostCPUGetInfo(virArch hostarch,
unsigned int *nodes,
unsigned int *sockets,
unsigned int *cores,
- unsigned int *threads);
+ unsigned int *threads,
+ unsigned int *l3_cache);
int virHostCPUGetKVMMaxVCPUs(void);
diff --git a/src/util/virhostcpupriv.h b/src/util/virhostcpupriv.h
index de30983..69d5e34 100644
--- a/src/util/virhostcpupriv.h
+++ b/src/util/virhostcpupriv.h
@@ -34,7 +34,8 @@ int virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
unsigned int *nodes,
unsigned int *sockets,
unsigned int *cores,
- unsigned int *threads);
+ unsigned int *threads,
+ unsigned int *l3_cache);
int virHostCPUGetStatsLinux(FILE *procstat,
int cpuNum,
diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c
index 8387956..2b2a680 100644
--- a/tests/virhostcputest.c
+++ b/tests/virhostcputest.c
@@ -44,7 +44,8 @@ linuxTestCompareFiles(const char *cpuinfofile,
if (virHostCPUGetInfoPopulateLinux(cpuinfo, arch,
&nodeinfo.cpus, &nodeinfo.mhz,
&nodeinfo.nodes, &nodeinfo.sockets,
- &nodeinfo.cores, &nodeinfo.threads) < 0) {
+ &nodeinfo.cores, &nodeinfo.threads,
+ &nodeinfo.l3_cache) < 0) {
if (virTestGetDebug()) {
if (virGetLastError())
VIR_TEST_DEBUG("\n%s\n", virGetLastErrorMessage());
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 24ebde2..2b85372 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -671,6 +671,7 @@ cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, "%-20s %d\n", _("Thread(s) per core:"), info.threads);
vshPrint(ctl, "%-20s %d\n", _("NUMA cell(s):"), info.nodes);
vshPrint(ctl, "%-20s %lu KiB\n", _("Memory size:"), info.memory);
+ vshPrint(ctl, "%-20s %d KiB\n", _("L3 cache size:"), info.l3_cache);
return true;
}
--
1.9.1
7 years, 10 months
[libvirt] [PATCH] NEWS: Add trailing periods to all sentences
by Andrea Bolognani
Suggested-by: John Ferlan <jferlan(a)redhat.com>
---
docs/news.xml | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/docs/news.xml b/docs/news.xml
index 909b4ca..672e988 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -24,7 +24,7 @@
<description>
Add the capability to allow group I/O throttling via a new
domain <disk> <iotune> subelement "group_name"
- to allow sharing I/O throttling quota between multiple drives
+ to allow sharing I/O throttling quota between multiple drives.
</description>
</change>
<change>
@@ -33,7 +33,7 @@
</summary>
<description>
New <code>libvirt-guest</code> nss module that translates libvirt
- guest names into IP addresses
+ guest names into IP addresses.
</description>
</change>
<change>
@@ -43,7 +43,7 @@
<description>
Logging-related settings like log outputs and filters can now be
adjusted during runtime using the admin interface without the
- necessity of the daemon's restart
+ necessity of the daemon's restart.
</description>
</change>
<change>
@@ -55,7 +55,7 @@
flag in order to return the host physical size in bytes
of the image container in the allocation field of the
_virStorageVolInfo structure. The --physical flag has been
- added to the virsh vol-info command to access the data
+ added to the virsh vol-info command to access the data.
</description>
</change>
<change>
@@ -73,7 +73,7 @@
Add support to get the count of branch instructions
executed, branch misses, bus cycles, stalled frontend
cpu cycles, stalled backend cpu cycles, and ref cpu
- cycles by applications running on the platform
+ cycles by applications running on the platform.
</description>
</change>
<change>
@@ -82,7 +82,7 @@
</summary>
<description>
Add a display of the <physical> size of a disk
- volume in the output of the volume XML
+ volume in the output of the volume XML.
</description>
</change>
<change>
@@ -93,7 +93,7 @@
virtio-pci provides several advantages over virtio-mmio, such
as the ability to hotplug devices and improved performance.
While opting in to virtio-pci has been possible for a while,
- newly-defined guests will now use it automatically
+ newly-defined guests will now use it automatically.
</description>
</change>
</section>
@@ -106,7 +106,7 @@
For an active domain, correct the physical value provided for
a raw sparse file backed storage and the allocation value provided
for a qcow2 file backed storage that hasn't yet been opened on
- the domain
+ the domain.
</description>
</change>
<change>
@@ -115,7 +115,7 @@
</summary>
<description>
The chardev detection code has been improved and can now handle this
- configuration properly
+ configuration properly.
</description>
</change>
<change>
@@ -138,7 +138,7 @@
</summary>
<description>
The shmem device can now utilize QEMU's ivshmem-plain and
- ivshmem-doorbell, more modern versions of ivshmem
+ ivshmem-doorbell, more modern versions of ivshmem.
</description>
</change>
<change>
@@ -153,7 +153,7 @@
<description>
The new libssh transport allows one to connect to a running
libvirtd via SSH, using the libssh library; for example:
- <tt>qemu+libssh://<i>server</i>/system</tt>
+ <tt>qemu+libssh://<i>server</i>/system</tt>.
</description>
</change>
<change>
@@ -162,7 +162,7 @@
</summary>
<description>
Add the capability to pass through a scsi_host HBA and the
- associated LUNs to the guest
+ associated LUNs to the guest.
</description>
</change>
<change>
@@ -190,7 +190,7 @@
e1000e, nec-xhci, vfio assigned devices) will be placed on
an Express controller (i.e. a pcie-root-port) instead of a
legacy PCI controller (i.e. pci-bridge) with the root ports
- added as needed
+ added as needed.
</description>
</change>
</section>
@@ -222,7 +222,7 @@
</summary>
<description>
List user-visible changes instead of single commits for a better
- high-level overview of differences between libvirt releases
+ high-level overview of differences between libvirt releases.
</description>
</change>
<change>
@@ -232,7 +232,7 @@
<description>
The libvirt website looked very cluttered and outdated; it has now
been completely overhauled, resulting in a design that's better
- organized and more pleasant to look at
+ organized and more pleasant to look at.
</description>
</change>
</section>
--
2.7.4
7 years, 10 months
[libvirt] Paradox cpu topology in capabilities outputs
by Qiao, Liyong
Hi,
I observe that virsh capabilities give wrong cpu topology on a multiple sockets host
taget@jfz1r04h13:~/libvirt$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 72
On-line CPU(s) list: 0-71
Thread(s) per core: 2
Core(s) per socket: 18
Socket(s): 2 <------------------------
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 63
Model name: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz
Stepping: 2
CPU MHz: 1201.660
CPU max MHz: 3600.0000
CPU min MHz: 1200.0000
BogoMIPS: 4590.78
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 46080K
NUMA node0 CPU(s): 0-17,36-53
NUMA node1 CPU(s): 18-35,54-71
But output of virsh capabilities only gives.
<topology sockets='1' cores='18' threads='2'/>
looking into code and got this:
https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/util/virhostcpu.c;h=f...
should we change it into
704<https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/util/virhostcpu.c;h=f...> *sockets += nodesockets;
This also affect nodeinfo.sockets.
Attached file is the full output of capabilities of the host
Best Regards
Eli Qiao(乔立勇)OpenStack Core team OTC Intel.
--
7 years, 10 months
[libvirt] [PATCH 00/11] tests: qemu: Add cpu hotplug testing
by Peter Krempa
Add some useful monitor infrastructure to simplify testing and add testing for
the cpu hotplug code. The code has some complex logic which was not covered
by current test suite.
Peter Krempa (11):
qemu: monitor: More strict checking of 'query-cpus' if hotplug is
supported
util: json: Add helper to reformat JSON strings
tests: qemu: Document qemuMonitorTestNewFromFile
qemu: Prepare for reuse of qemuDomainSetVcpusLive
qemu: Move cpu hotplug code into qemu_hotplug.c
tests: qemumonitor: Propagate better error messages
tests: qemu: monitor: Add helpers to test full command syntax
tests: qemu: Add helper to load full monitor conversation from file
tests: hotplug: Add test infrastructure for testing qemu CPU hotplug
code
tests: hotplug: Add test data for legacy cpu hotplug
tests: hotplug: Test CPU hotplug with ppc64 data
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 319 -----------
src/qemu/qemu_hotplug.c | 328 ++++++++++++
src/qemu/qemu_hotplug.h | 7 +
src/qemu/qemu_monitor.c | 6 +-
src/qemu/qemu_monitor_json.c | 6 +-
src/qemu/qemu_monitor_json.h | 3 +-
src/util/virjson.c | 29 +
src/util/virjson.h | 2 +
tests/qemuagenttest.c | 3 +-
tests/qemuhotplugtest.c | 194 +++++++
tests/qemuhotplugtestcpus/ppc64-bulk-domain.xml | 20 +
tests/qemuhotplugtestcpus/ppc64-bulk-monitor.json | 593 +++++++++++++++++++++
.../qemuhotplugtestcpus/ppc64-bulk-result-conf.xml | 64 +++
.../qemuhotplugtestcpus/ppc64-bulk-result-live.xml | 72 +++
.../qemuhotplugtestcpus/x86-modern-bulk-domain.xml | 21 +
.../x86-modern-bulk-monitor.json | 471 ++++++++++++++++
.../x86-modern-bulk-result-conf.xml | 40 ++
.../x86-modern-bulk-result-live.xml | 48 ++
tests/qemuhotplugtestcpus/x86-old-bulk-domain.xml | 21 +
.../qemuhotplugtestcpus/x86-old-bulk-monitor.json | 193 +++++++
.../x86-old-bulk-result-conf.xml | 30 ++
.../x86-old-bulk-result-live.xml | 38 ++
tests/qemumonitorjsontest.c | 2 +-
tests/qemumonitortestutils.c | 322 ++++++++++-
tests/qemumonitortestutils.h | 12 +-
26 files changed, 2505 insertions(+), 340 deletions(-)
create mode 100644 tests/qemuhotplugtestcpus/ppc64-bulk-domain.xml
create mode 100644 tests/qemuhotplugtestcpus/ppc64-bulk-monitor.json
create mode 100644 tests/qemuhotplugtestcpus/ppc64-bulk-result-conf.xml
create mode 100644 tests/qemuhotplugtestcpus/ppc64-bulk-result-live.xml
create mode 100644 tests/qemuhotplugtestcpus/x86-modern-bulk-domain.xml
create mode 100644 tests/qemuhotplugtestcpus/x86-modern-bulk-monitor.json
create mode 100644 tests/qemuhotplugtestcpus/x86-modern-bulk-result-conf.xml
create mode 100644 tests/qemuhotplugtestcpus/x86-modern-bulk-result-live.xml
create mode 100644 tests/qemuhotplugtestcpus/x86-old-bulk-domain.xml
create mode 100644 tests/qemuhotplugtestcpus/x86-old-bulk-monitor.json
create mode 100644 tests/qemuhotplugtestcpus/x86-old-bulk-result-conf.xml
create mode 100644 tests/qemuhotplugtestcpus/x86-old-bulk-result-live.xml
--
2.10.2
7 years, 10 months
[libvirt] [PATCH v3 0/8] aggregate multiple pcie-root-ports onto a single slot
by Laine Stump
Another rebase of the series with no other changes
Laine Stump (8):
conf: use struct instead of int for each slot in
virDomainPCIAddressBus
conf: eliminate concept of "reserveEntireSlot"
conf: eliminate repetitive code in virDomainPCIAddressGetNextSlot()
conf: start search for next unused PCI address at same slot as
previous find
conf: new function virDomainPCIAddressIsMulti()
qemu: use virDomainPCIAddressIsMulti() to determine multifunction
setting
conf: aggregate multiple devices on a slot when assigning PCI
addresses
conf: aggregate multiple pcie-root-ports onto a single slot
src/conf/domain_addr.c | 290 ++++++++++++++-------
src/conf/domain_addr.h | 48 +++-
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 16 +-
src/qemu/qemu_domain_address.c | 35 ++-
.../qemuxml2argv-pcie-root-port.args | 5 +-
.../qemuxml2argv-pcie-switch-upstream-port.args | 5 +-
.../qemuxml2argv-q35-default-devices-only.args | 7 +-
.../qemuxml2argv-q35-multifunction.args | 43 +++
.../qemuxml2argv-q35-multifunction.xml | 51 ++++
.../qemuxml2argv-q35-pcie-autoadd.args | 30 ++-
tests/qemuxml2argvdata/qemuxml2argv-q35-pcie.args | 28 +-
.../qemuxml2argv-q35-virt-manager-basic.args | 13 +-
.../qemuxml2argv-q35-virtio-pci.args | 28 +-
tests/qemuxml2argvtest.c | 25 ++
.../qemuxml2xmlout-pcie-root-port.xml | 2 +-
.../qemuxml2xmlout-pcie-switch-upstream-port.xml | 4 +-
.../qemuxml2xmlout-q35-default-devices-only.xml | 8 +-
.../qemuxml2xmlout-q35-multifunction.xml | 120 +++++++++
.../qemuxml2xmlout-q35-pcie-autoadd.xml | 52 ++--
.../qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie.xml | 48 ++--
.../qemuxml2xmlout-q35-virt-manager-basic.xml | 20 +-
.../qemuxml2xmlout-q35-virtio-pci.xml | 48 ++--
tests/qemuxml2xmltest.c | 25 ++
24 files changed, 676 insertions(+), 276 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-multifunction.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-multifunction.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-multifunction.xml
--
2.7.4
7 years, 10 months
[libvirt] [PATCH v4] libxl: define a per-domain logger.
by Cédric Bosdonnat
libxl doesn't provide a way to write one log for each domain. Thus
we need to demux the messages. If our logger doesn't know to which
domain to attribute a message, then it will write it to the default
log file.
Starting with Xen 4.9 (commit f9858025 and following), libxl will
write the domain ID in an easy to grab manner. The logger introduced
by this commit will use it to demux the libxl log messages.
Thanks to the default log file, this logger will also work with older
versions of Xen.
---
* v4: delay the log file opening to the first message write.
* v3: add JSON-formatted libxl_domain_config to the newly opened
file when creating a guest.
* v2: addressed Jim's comments
src/Makefile.am | 1 +
src/libxl/libxl_conf.c | 38 +------
src/libxl/libxl_conf.h | 4 +-
src/libxl/libxl_domain.c | 7 ++
src/libxl/libxl_driver.c | 2 +
src/libxl/libxl_logger.c | 257 +++++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_logger.h | 40 ++++++++
7 files changed, 312 insertions(+), 37 deletions(-)
create mode 100644 src/libxl/libxl_logger.c
create mode 100644 src/libxl/libxl_logger.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 0dd2faaf6..58e3108a6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -851,6 +851,7 @@ LIBXL_DRIVER_SOURCES = \
libxl/libxl_capabilities.c libxl/libxl_capabilities.h \
libxl/libxl_domain.c libxl/libxl_domain.h \
libxl/libxl_driver.c libxl/libxl_driver.h \
+ libxl/libxl_logger.c libxl/libxl_logger.h \
libxl/libxl_migration.c libxl/libxl_migration.h
UML_DRIVER_SOURCES = \
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index b569ddad8..ac83b51c7 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -76,9 +76,7 @@ libxlDriverConfigDispose(void *obj)
virObjectUnref(cfg->caps);
libxl_ctx_free(cfg->ctx);
- xtl_logger_destroy(cfg->logger);
- if (cfg->logger_file)
- VIR_FORCE_FCLOSE(cfg->logger_file);
+ libxlLoggerFree(cfg->logger);
VIR_FREE(cfg->configDir);
VIR_FREE(cfg->autostartDir);
@@ -1356,8 +1354,6 @@ libxlDriverConfigPtr
libxlDriverConfigNew(void)
{
libxlDriverConfigPtr cfg;
- char *log_file = NULL;
- xentoollog_level log_level = XTL_DEBUG;
char ebuf[1024];
unsigned int free_mem;
@@ -1386,9 +1382,6 @@ libxlDriverConfigNew(void)
if (VIR_STRDUP(cfg->channelDir, LIBXL_CHANNEL_DIR) < 0)
goto error;
- if (virAsprintf(&log_file, "%s/libxl-driver.log", cfg->logDir) < 0)
- goto error;
-
if (virFileMakePath(cfg->logDir) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to create log dir '%s': %s"),
@@ -1397,37 +1390,13 @@ libxlDriverConfigNew(void)
goto error;
}
- if ((cfg->logger_file = fopen(log_file, "a")) == NULL) {
- VIR_ERROR(_("Failed to create log file '%s': %s"),
- log_file, virStrerror(errno, ebuf, sizeof(ebuf)));
- goto error;
- }
- VIR_FREE(log_file);
-
- switch (virLogGetDefaultPriority()) {
- case VIR_LOG_DEBUG:
- log_level = XTL_DEBUG;
- break;
- case VIR_LOG_INFO:
- log_level = XTL_INFO;
- break;
- case VIR_LOG_WARN:
- log_level = XTL_WARN;
- break;
- case VIR_LOG_ERROR:
- log_level = XTL_ERROR;
- break;
- }
-
- cfg->logger =
- (xentoollog_logger *)xtl_createlogger_stdiostream(cfg->logger_file,
- log_level, XTL_STDIOSTREAM_SHOW_DATE);
+ cfg->logger = libxlLoggerNew(cfg->logDir, virLogGetDefaultPriority());
if (!cfg->logger) {
VIR_ERROR(_("cannot create logger for libxenlight, disabling driver"));
goto error;
}
- if (libxl_ctx_alloc(&cfg->ctx, LIBXL_VERSION, 0, cfg->logger)) {
+ if (libxl_ctx_alloc(&cfg->ctx, LIBXL_VERSION, 0, (xentoollog_logger *)cfg->logger)) {
VIR_ERROR(_("cannot initialize libxenlight context, probably not "
"running in a Xen Dom0, disabling driver"));
goto error;
@@ -1478,7 +1447,6 @@ libxlDriverConfigNew(void)
return cfg;
error:
- VIR_FREE(log_file);
virObjectUnref(cfg);
return NULL;
}
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 851f3afb4..69d78851a 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -41,6 +41,7 @@
# include "locking/lock_manager.h"
# include "virfirmware.h"
# include "libxl_capabilities.h"
+# include "libxl_logger.h"
# define LIBXL_DRIVER_NAME "xenlight"
# define LIBXL_VNC_PORT_MIN 5900
@@ -74,8 +75,7 @@ struct _libxlDriverConfig {
unsigned int version;
/* log stream for driver-wide libxl ctx */
- FILE *logger_file;
- xentoollog_logger *logger;
+ libxlLoggerPtr logger;
/* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */
libxl_ctx *ctx;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 5cde576ef..fbe7ee5ff 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -809,6 +809,8 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
VIR_FREE(xml);
}
+ libxlLoggerCloseFile(cfg->logger, vm->def->id);
+
virDomainObjRemoveTransientDef(vm);
virObjectUnref(cfg);
}
@@ -1127,6 +1129,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
libxl_asyncprogress_how aop_console_how;
libxl_domain_restore_params params;
unsigned int hostdev_flags = VIR_HOSTDEV_SP_PCI;
+ char *config_json = NULL;
#ifdef LIBXL_HAVE_PVUSB
hostdev_flags |= VIR_HOSTDEV_SP_USB;
@@ -1290,6 +1293,9 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
* be cleaned up if there are any subsequent failures.
*/
vm->def->id = domid;
+ config_json = libxl_domain_config_to_json(cfg->ctx, &d_config);
+
+ libxlLoggerOpenFile(cfg->logger, domid, vm->def->name, config_json);
/* Always enable domain death events */
if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW))
@@ -1366,6 +1372,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
cleanup:
libxl_domain_config_dispose(&d_config);
+ VIR_FREE(config_json);
VIR_FREE(dom_xml);
VIR_FREE(managed_save_path);
virDomainDefFree(def);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 7e5d9b69e..325636c9a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -406,6 +406,8 @@ libxlReconnectDomain(virDomainObjPtr vm,
/* Update domid in case it changed (e.g. reboot) while we were gone? */
vm->def->id = d_info.domid;
+ libxlLoggerOpenFile(cfg->logger, vm->def->id, vm->def->name, NULL);
+
/* Update hostdev state */
if (virHostdevUpdateActiveDomainDevices(hostdev_mgr, LIBXL_DRIVER_NAME,
vm->def, hostdev_flags) < 0)
diff --git a/src/libxl/libxl_logger.c b/src/libxl/libxl_logger.c
new file mode 100644
index 000000000..437dbb34b
--- /dev/null
+++ b/src/libxl/libxl_logger.c
@@ -0,0 +1,257 @@
+/*
+ * libxl_logger.c: libxl logger implementation
+ *
+ * Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ *
+ * 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:
+ * Cédric Bosdonnat <cbosdonnat(a)suse.com>
+ */
+#include <config.h>
+
+#include <string.h>
+#include <libxl.h>
+
+#include "internal.h"
+#include "libxl_logger.h"
+#include "util/viralloc.h"
+#include "util/virerror.h"
+#include "util/virfile.h"
+#include "util/virhash.h"
+#include "util/virstring.h"
+#include "util/virtime.h"
+
+#define VIR_FROM_THIS VIR_FROM_LIBXL
+
+VIR_LOG_INIT("libxl.libxl_logger");
+
+typedef struct xentoollog_logger_libvirt xentoollog_logger_libvirt;
+
+typedef struct {
+ FILE *handle;
+ char *path;
+} libxlLoggerFile;
+
+struct xentoollog_logger_libvirt {
+ xentoollog_logger vtable;
+ xentoollog_level minLevel;
+ const char *logDir;
+
+ /* map storing the opened fds: "domid" -> FILE* */
+ virHashTablePtr files;
+ FILE *defaultLogFile;
+};
+
+static void
+libxlLoggerFileFree(void *payload, const void *key ATTRIBUTE_UNUSED)
+{
+ libxlLoggerFile *file = payload;
+ if (file->handle) {
+ VIR_FORCE_FCLOSE(file->handle);
+ file->handle = NULL;
+ }
+ VIR_FREE(file->path);
+}
+
+static int
+libxlLoggerFileOpen(libxlLoggerFile *file) {
+ int ret = 0;
+ char ebuf[1024];
+
+ if (!file->handle && !(file->handle = fopen(file->path, "a"))) {
+ VIR_WARN("Failed to open log file %s: %s",
+ file->path, virStrerror(errno, ebuf, sizeof(ebuf)));
+ ret = -1;
+ }
+
+ return ret;
+}
+
+ATTRIBUTE_FMT_PRINTF(5, 0) static void
+libvirt_vmessage(xentoollog_logger *logger_in,
+ xentoollog_level level,
+ int errnoval,
+ const char *context,
+ const char *format,
+ va_list args)
+{
+ xentoollog_logger_libvirt *lg = (xentoollog_logger_libvirt *)logger_in;
+ FILE *logFile = lg->defaultLogFile;
+ char timestamp[VIR_TIME_STRING_BUFLEN];
+ char *message = NULL;
+ char *start, *end;
+ char ebuf[1024];
+
+ VIR_DEBUG("libvirt_vmessage: context='%s' format='%s'", context, format);
+
+ if (level < lg->minLevel)
+ return;
+
+ if (virVasprintf(&message, format, args) < 0)
+ return;
+
+ /* Should we print to a domain-specific log file? */
+ if ((start = strstr(message, ": Domain ")) &&
+ (end = strstr(start + 9, ":"))) {
+ libxlLoggerFile *file = NULL;
+
+ start = start + 9;
+ *end = '\0';
+
+ file = virHashLookup(lg->files, start);
+ if (file) {
+ ignore_value(libxlLoggerFileOpen(file));
+ logFile = file->handle;
+ }
+
+ *end = ':';
+ }
+
+ /* Do the actual print to the log file */
+ if (virTimeStringNowRaw(timestamp) < 0)
+ timestamp[0] = '\0';
+
+ fprintf(logFile, "%s: ", timestamp);
+ if (context)
+ fprintf(logFile, "%s: ", context);
+
+ fprintf(logFile, "%s", message);
+
+ if (errnoval >= 0)
+ fprintf(logFile, ": %s", virStrerror(errnoval, ebuf, sizeof(ebuf)));
+
+ fputc('\n', logFile);
+ fflush(logFile);
+
+ VIR_FREE(message);
+}
+
+static void
+libvirt_progress(xentoollog_logger *logger_in ATTRIBUTE_UNUSED,
+ const char *context ATTRIBUTE_UNUSED,
+ const char *doingwhat ATTRIBUTE_UNUSED,
+ int percent ATTRIBUTE_UNUSED,
+ unsigned long done ATTRIBUTE_UNUSED,
+ unsigned long total ATTRIBUTE_UNUSED)
+{
+ /* This function purposedly does nothing: it's no logging info */
+}
+
+static void
+libvirt_destroy(xentoollog_logger *logger_in)
+{
+ xentoollog_logger_libvirt *lg = (xentoollog_logger_libvirt*)logger_in;
+ VIR_FREE(lg);
+}
+
+
+libxlLoggerPtr libxlLoggerNew(const char *logDir,
+ virLogPriority minLevel)
+{
+ xentoollog_logger_libvirt logger;
+ libxlLoggerPtr logger_out = NULL;
+ char *path = NULL;
+
+ switch (minLevel) {
+ case VIR_LOG_DEBUG:
+ logger.minLevel = XTL_DEBUG;
+ break;
+ case VIR_LOG_INFO:
+ logger.minLevel = XTL_INFO;
+ break;
+ case VIR_LOG_WARN:
+ logger.minLevel = XTL_WARN;
+ break;
+ case VIR_LOG_ERROR:
+ logger.minLevel = XTL_ERROR;
+ break;
+ }
+ logger.logDir = logDir;
+
+ if ((logger.files = virHashCreate(3, libxlLoggerFileFree)) == NULL)
+ return NULL;
+
+ if (virAsprintf(&path, "%s/libxl-driver.log", logDir) < 0)
+ goto error;
+
+ if ((logger.defaultLogFile = fopen(path, "a")) == NULL)
+ goto error;
+
+ logger_out = XTL_NEW_LOGGER(libvirt, logger);
+
+ cleanup:
+ VIR_FREE(path);
+ return logger_out;
+
+ error:
+ virHashFree(logger.files);
+ goto cleanup;
+}
+
+void libxlLoggerFree(libxlLoggerPtr logger)
+{
+ xentoollog_logger *xtl_logger = (xentoollog_logger*)logger;
+ if (logger->defaultLogFile)
+ VIR_FORCE_FCLOSE(logger->defaultLogFile);
+ virHashFree(logger->files);
+ xtl_logger_destroy(xtl_logger);
+}
+
+void libxlLoggerOpenFile(libxlLoggerPtr logger, int id,
+ const char *name,
+ const char *domain_config)
+{
+ FILE *logFile = NULL;
+ char *domidstr = NULL;
+ libxlLoggerFile *file;
+
+ if (VIR_ALLOC(file) < 0)
+ return;
+
+ if (virAsprintf(&file->path, "%s/%s.log", logger->logDir, name) < 0 ||
+ virAsprintf(&domidstr, "%d", id) < 0)
+ goto error;
+
+ ignore_value(virHashAddEntry(logger->files, domidstr, file));
+
+ /* domain_config is non NULL only when starting a new domain */
+ if (domain_config) {
+ if (libxlLoggerFileOpen(file) < 0)
+ goto cleanup;
+
+ fprintf(logFile, "Domain start: %s\n", domain_config);
+ fflush(logFile);
+ }
+ goto cleanup;
+
+ error:
+ VIR_FREE(file->path);
+ VIR_FREE(file);
+
+ cleanup:
+ VIR_FREE(domidstr);
+}
+
+void libxlLoggerCloseFile(libxlLoggerPtr logger, int id)
+{
+ char *domidstr = NULL;
+ if (virAsprintf(&domidstr, "%d", id) < 0)
+ return;
+
+ ignore_value(virHashRemoveEntry(logger->files, domidstr));
+
+ VIR_FREE(domidstr);
+}
diff --git a/src/libxl/libxl_logger.h b/src/libxl/libxl_logger.h
new file mode 100644
index 000000000..92b222578
--- /dev/null
+++ b/src/libxl/libxl_logger.h
@@ -0,0 +1,40 @@
+/*
+ * libxl_logger.h: libxl logger implementation
+ *
+ * Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ *
+ * 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:
+ * Cédric Bosdonnat <cbosdonnat(a)suse.com>
+ */
+
+#ifndef __LIBXL_LOGGER_H
+# define __LIBXL_LOGGER_H
+
+# include "util/virlog.h"
+
+typedef struct xentoollog_logger_libvirt libxlLogger;
+typedef libxlLogger *libxlLoggerPtr;
+
+libxlLoggerPtr libxlLoggerNew(const char *logDir,
+ virLogPriority minLevel);
+void libxlLoggerFree(libxlLoggerPtr logger);
+
+void libxlLoggerOpenFile(libxlLoggerPtr logger, int id, const char *name,
+ const char *domain_config);
+void libxlLoggerCloseFile(libxlLoggerPtr logger, int id);
+
+#endif /* __LIBXL_LOGGER_H */
--
2.11.0
7 years, 10 months
[libvirt] Do different Virgil3D users running have the same CANVAS fingerprint?
by bancfc@openmailbox.org
Background:
Canvas fingerprinting is a technique to track users based on their GPUs.
https://en.wikipedia.org/wiki/Canvas_fingerprinting
Someone did some testing and the good news is the fingerprint is common
for all users of the same OS across all KVM users because it presents
the same virtual GPU/drivers for everybody.
What I need your help to find out is whether this holds for Virgil3D
users that enable graphics acceleration. (I am running on Debian and the
libvirt version in the repos is too old to have this included also I
don't have multiple machines)
To test this you need:
To run plain FireFox on a virtualized distro (with GL acceleration
enabled in libvirt) of your choice and visit
https://browserleaks.com/canvas . Then repeat the same steps with that
same distro (in a VM) on another physical machine and compare values.
A good result is if you see the same numbers for both machines. That
means the virtual device fingerprint is uniform for all virtual users.
7 years, 10 months
[libvirt] [PATCH] libxl: fix usb inputs loop error
by Cédric Bosdonnat
List indexes where mixed up in the code looping over the USB
input devices.
---
src/libxl/libxl_conf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index ac83b51c7..1053e60a1 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -479,7 +479,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
if (VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) < 0)
return -1;
#else
- if (i > 1) {
+ if (nusbdevice > 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("libxenlight supports only one input device"));
return -1;
@@ -487,7 +487,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
#endif
#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
- usbdevice = &b_info->u.hvm.usbdevice_list[i];
+ usbdevice = &b_info->u.hvm.usbdevice_list[nusbdevice - 1];
#else
usbdevice = &b_info->u.hvm.usbdevice;
#endif
--
2.11.0
7 years, 10 months