[libvirt] [PATCH] maint: doc fix
by Eric Blake
* src/libvirt.c: Avoid duplicate word.
---
I'm pushing this under the trivial rule.
src/libvirt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 4188b45..ff2ac93 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3297,7 +3297,7 @@ error:
* @flags: currently unused, pass 0
*
* Reads a domain XML configuration document, and generates
- * generates a native configuration file describing the domain.
+ * a native configuration file describing the domain.
* The format of the native data is hypervisor dependant.
*
* Returns a 0 terminated UTF-8 encoded native config datafile, or NULL in case of error.
--
1.7.3.3
13 years, 11 months
[libvirt] [PATCH 0/8] Early preview: Re-factoring XDR RPC code
by Daniel P. Berrange
NB: This patch series isn't intended to be applied yet.
The current remote driver and libvirtd daemon have a horrible mix
of network I/O, RPC dispatch and RPC handling functionality. It
it neccessary to introduce a new daemon to provide a lock manager
for VM disks. Doing so would effectively require cut+paste of a
large part of libvirtd code since there are no reusable APis in
it. Likewise for the client side.
To address this problem, this series is an attempt to produce a
reusable set of APIs for building RPC servers and clients. The
new APIs will handle all the networking/sockets functionality
and all the RPC dispatch/serialization/deserialization code.
This will enable libvirtd and the remote driver to be gutted,
so that they only contain the code for actually implementing
the RPC handlers. Thus a lock daemon + lock plugin can be
provided without any code duplication.
This will also make it far easier for us to introduce new
RPC programs, eg an administrative program to allow libvirtd
itself to be manipulated, say, to changing logging levels on
the fly, kill mis-behaving network client, etc, etc. It would
also make it practical to experiment with splitting libvirtd
up into smaller daemons each handling one area of functionality.
This would in turn make it practical to write useful SELinux
policy for confining libvirt daemons
This series is *far* from complete. The streams stuff is
completely missing in the new APis. I have also not yet gutted
libvirtd, only the remote driver. It is also not fully tested
for ABI wire compatibility with existing libvirtd, though I
believe it is correctly preserving ABI.
The diffstat is slightly mis-leading because lots of code
remains to be deleted from daemon/libvirtd.c and
daemon/dispatch.c. None the less, it is expected that the
total lines will increase, but this wll be offset by the
improved code clarity and separation of functionality.
Daniel
daemon/event.c | 3
src/Makefile.am | 90 +
src/remote/remote_driver.c | 2530 ++++++--------------------------------
src/rpc/virnetclient.c | 1237 ++++++++++++++++++
src/rpc/virnetclient.h | 60
src/rpc/virnetclientprogram.c | 258 +++
src/rpc/virnetclientprogram.h | 71 +
src/rpc/virnetclientsaslcontext.c | 246 +++
src/rpc/virnetclientsaslcontext.h | 66
src/rpc/virnetmessage.c | 215 +++
src/rpc/virnetmessage.h | 31
src/rpc/virnetprotocol.c | 108 +
src/rpc/virnetprotocol.h | 81 +
src/rpc/virnetprotocol.x | 162 ++
src/rpc/virnetserver.c | 654 +++++++++
src/rpc/virnetserver.h | 74 +
src/rpc/virnetserverclient.c | 974 ++++++++++++++
src/rpc/virnetserverclient.h | 40
src/rpc/virnetservermessage.h | 20
src/rpc/virnetserverprogram.c | 437 ++++++
src/rpc/virnetserverprogram.h | 76 +
src/rpc/virnetserverservice.c | 208 +++
src/rpc/virnetserverservice.h | 32
src/rpc/virnetsocket.c | 715 ++++++++++
src/rpc/virnetsocket.h | 97 +
src/rpc/virnettlscontext.c | 611 +++++++++
src/rpc/virnettlscontext.h | 63
src/util/logging.c | 4
src/util/threadpool.c | 178 ++
src/util/threadpool.h | 23
src/virtlockd.c | 620 +++++++++
31 files changed, 7866 insertions(+), 2118 deletions(-)
13 years, 11 months
[libvirt] contribution: qemu hook script to manage guests network bandwidth
by Dominik Klein
Hi
we had the need to manage guests bandwidth. Therefore I wrote a qemu
hook script that achieves this and, if there is any interest in that,
would like to contribute it to the project.
This script will only work on linux hosts. It effectively limits the
bandwidth a guest can _send_. It only somewhat effectively limits the
bandwidth a guest can _receive_. While well behaving tcp connections
slow down when packets are being delayed/dropped, with udp, we are
facing a different situation. During my tests, udp was always way slower
(factor 10) than actually configured (using iperf -u). Since only tcp
matters to us in this situation, we consider it "good enough".
Also: This mechanism does by no means protect you from ddos or the like.
So what does the script do?
The script uses iptables to mark packets from- and to a virtual machine.
Depending on these marks, packets will be filtered into tc classes which
limit bandwidth to a configurable amount. The configuration allows for
groups of vms which share an amount of bandwidth while each machine has
its guaranteed bandwidth in high network usage situations.
Documentation is part of the script. If you like, feel free to include it.
If you have any comments or questions, talk! :)
Regards
Dominik
13 years, 11 months
[libvirt] [C# bindings][PATCH]
by arnaud.champion@devatom.fr
?Hi,
here is another patch for C# bindings. I have update our project DAVIM with latest C# bindings and it show some naming errors. This patch correct it.
Arnaud
13 years, 11 months
[libvirt] "virsh setvcpus" does not work.
by Ken'ichi Ohmichi
Hi,
I tested "virsh setvcpus" command and it did not work like the following:
# virsh setvcpus RHEL5.5GA_Guest.img 2
error: internal error unable to execute QEMU command 'cpu_set': The command cpu_set has not been ound
#
Has this problem been fixed already on upstream ?
o Test environment
Host OS: RHEL6.0 (x86_64)
qemu-kvm: 0.12.1.2-2.113.el6
libvirt : 0.8.1-27.el6
Guetst OS: RHEL5.5
o GDB output
(gdb) b qerror_report_internal
Breakpoint 1 at 0x497a50: file qerror.c, line 412.
(gdb) c
Continuing.
[New Thread 0x7f726a9fc710 (LWP 23964)]
Breakpoint 1, qerror_report_internal (
file=0x57e9d0 "/builddir/build/BUILD/qemu-kvm-0.12.1.2/monitor.c", linenr=4427,
func=0x582af0 "handle_qmp_command",
fmt=0x57ee90 "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }")
at qerror.c:412
412 {
(gdb) bt
#0 qerror_report_internal (
file=0x57e9d0 "/builddir/build/BUILD/qemu-kvm-0.12.1.2/monitor.c", linenr=4427,
func=0x582af0 "handle_qmp_command",
fmt=0x57ee90 "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }")
at qerror.c:412
#1 0x00000000004133ae in handle_qmp_command (parser=<value optimized out>,
tokens=<value optimized out>) at /usr/src/debug/qemu-kvm-0.12.1.2/monitor.c:4427
#2 0x0000000000495d52 in json_message_process_token (lexer=0x1ab5d70, token=0x22037b0,
type=JSON_OPERATOR, x=61, y=9170) at json-streamer.c:56
#3 0x0000000000495ab3 in json_lexer_feed_char (lexer=0x1ab5d70, ch=125 '}')
at json-lexer.c:299
#4 0x0000000000495be7 in json_lexer_feed (lexer=0x1ab5d70,
buffer=0x7ffff19b4510 "}F\232\001", size=1) at json-lexer.c:322
#5 0x00000000004124d2 in monitor_control_read (opaque=<value optimized out>,
buf=<value optimized out>, size=<value optimized out>)
at /usr/src/debug/qemu-kvm-0.12.1.2/monitor.c:4478
#6 0x00000000004b6b8a in qemu_chr_read (opaque=0x19a43a0) at qemu-char.c:154
#7 tcp_chr_read (opaque=0x19a43a0) at qemu-char.c:2072
#8 0x000000000040b4af in main_loop_wait (timeout=1000)
at /usr/src/debug/qemu-kvm-0.12.1.2/vl.c:4234
#9 0x0000000000428a2a in kvm_main_loop ()
at /usr/src/debug/qemu-kvm-0.12.1.2/qemu-kvm.c:2133
#10 0x000000000040e5cb in main_loop (argc=<value optimized out>,
argv=<value optimized out>, envp=<value optimized out>)
at /usr/src/debug/qemu-kvm-0.12.1.2/vl.c:4444
#11 main (argc=<value optimized out>, argv=<value optimized out>,
envp=<value optimized out>) at /usr/src/debug/qemu-kvm-0.12.1.2/vl.c:6601
(gdb)
Thanks
Ken'ichi Ohmichi
13 years, 11 months
Re: [libvirt] system / session URI
by arnaud.champion@devatom.fr
Okay,
thanks for the explaination. This explain why I can't do some network thing with session URI ;)
Thanks a lot
Regards,
Arnaud
----------------------------------------
De: "Eric Blake" <eblake(a)redhat.com>
Envoyé: mercredi 15 décembre 2010 23:09
A: arnaud.champion(a)devatom.fr
Objet: Re: [libvirt] system / session URI
On 12/15/2010 02:19 PM, arnaud.champion(a)devatom.fr wrote:
> ?Hi,
>
> Can someone explain (or point me to a document that explain) what are the differences between these two URI :
>
> qemu+tcp://xxx.xxx.xxx.xxx/system
> qemu+tcp://xxx.xxx.xxx.xxx/session
http://libvirt.org/uri.html#URI_qemu
System URIs connect to the system libvirtd daemon (started by system
init scripts), which is shared among all users on the machine, and which
allows access to anything that requires superuser capabilities (such as
creating tun devices for networking).
Session URIs connect to a per-user daemon (which will be started
automatically if needed), and which cannot access anything that the user
cannot access (and unfortunately, given that no one has yet figured out
how to make Linux share tun devices with ordinary users, that means that
session guests are currently rather limited because they will not have
networking support). The goal is to make things support full
virtualization under session URIs, once the kernel adds the support we
need for networking.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
13 years, 11 months
[libvirt] system / session URI
by arnaud.champion@devatom.fr
?Hi,
Can someone explain (or point me to a document that explain) what are the differences between these two URI :
qemu+tcp://xxx.xxx.xxx.xxx/system
qemu+tcp://xxx.xxx.xxx.xxx/session
Regards,
Arnaud
13 years, 11 months
[libvirt] [PATCH] Introduce yet another migration version in API.
by Daniel P. Berrange
Migration just seems togo from bad to worse. We already had to
introduce a second migration protocol when adding the QEMU driver,
since the one from Xen was insufficiently flexible to cope with
passing the data the QEMU driver required.
It turns out that this protocol still has some flaws that we
need to address. The current sequence is
* Src: DumpXML
- Generate XML to pass to dst
* Dst: Prepare
- Get ready to accept incoming VM
- Generate optional cookie to pass to src
* Src: Perform
- Start migration and wait for send completion
- Kill off VM if successful, resume if failed
* Dst: Finish
- Wait for recv completion and check status
- Kill off VM if unsuccessful
The problems with this are:
- Since the first step is a generic 'DumpXML' call, we can't
add in other migration specific data. eg, we can't include
any VM lease data from lock manager plugins
- Since the first step is a generic 'DumpXML' call, we can't
emit any 'migration begin' event on the source, or have
any hook that runs right at the start of the process
- Since there is no final step on the source, if the Finish
method fails to receive all migration data & has to kill
the VM, then there's no way to resume the original VM
on the source
This patch attempts to introduce a version 3 that uses the
improved 5 step sequence
* Src: Begin
- Generate XML to pass to dst
- Generate optional cookie to pass to dst
* Dst: Prepare
- Get ready to accept incoming VM
- Generate optional cookie to pass to src
* Src: Perform
- Start migration and wait for send completion
- Generate optional cookie to pass to dst
* Dst: Finish
- Wait for recv completion and check status
- Kill off VM if failed, resume if success
- Generate optional cookie to pass to src
* Src: Confirm
- Kill off VM if success, resume if failed
The API is designed to allow both input and output cookies
in all methods where applicable. This lets us pass around
arbitrary extra driver specific data between src & dst during
migration. Combined with the extra 'Begin' method this lets
us pass lease information from source to dst at the start of
migration
Moving the killing of the source VM out of Perform and
into Confirm, means we can now recover if the dst host
can't successfully Finish receiving migration data.
---
src/driver.h | 64 +++++++++++++++++++
src/libvirt.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++
src/libvirt_internal.h | 7 ++
3 files changed, 235 insertions(+), 0 deletions(-)
diff --git a/src/driver.h b/src/driver.h
index e3a232d..b2514ed 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -486,6 +486,65 @@ typedef int
virStreamPtr st,
unsigned int flags);
+typedef char *
+ (*virDrvDomainMigrateBegin3)
+ (virConnectPtr dconn,
+ char **cookiesrc,
+ int *cookiesrclen,
+ const char *uri,
+ unsigned long flags,
+ const char *dname,
+ unsigned long resource);
+
+typedef int
+ (*virDrvDomainMigratePrepare3)
+ (virConnectPtr dconn,
+ const char *cookiesrc,
+ int cookiesrclen,
+ char **cookiedst,
+ int *cookiedstlen,
+ const char *uri_in,
+ char **uri_out,
+ unsigned long flags,
+ const char *dname,
+ unsigned long resource,
+ const char *dom_xml);
+
+typedef int
+ (*virDrvDomainMigratePerform3)
+ (virDomainPtr domain,
+ char **cookiesrc,
+ int *cookiesrclen,
+ const char *cookiedst,
+ int cookiedstlen,
+ const char *uri,
+ unsigned long flags,
+ const char *dname,
+ unsigned long resource);
+
+typedef virDomainPtr
+ (*virDrvDomainMigrateFinish3)
+ (virConnectPtr dconn,
+ const char *dname,
+ const char *cookiesrc,
+ int cookiesrclen,
+ char **cookiedst,
+ int *cookiedstlen,
+ const char *uri,
+ unsigned long flags,
+ int retcode);
+
+typedef int
+ (*virDrvDomainMigrateConfirm3)
+ (virConnectPtr dconn,
+ const char *dname,
+ const char *cookiesrc,
+ int cookiesrclen,
+ const char *cookiedst,
+ int cookiedstlen,
+ const char *uri,
+ unsigned long flags,
+ int retcode);
/**
* _virDriver:
@@ -604,6 +663,11 @@ struct _virDriver {
virDrvDomainSetMemoryParameters domainSetMemoryParameters;
virDrvDomainGetMemoryParameters domainGetMemoryParameters;
virDrvDomainOpenConsole domainOpenConsole;
+ virDrvDomainMigrateBegin3 domainMigrateBegin3;
+ virDrvDomainMigratePrepare3 domainMigratePrepare3;
+ virDrvDomainMigratePerform3 domainMigratePerform3;
+ virDrvDomainMigrateFinish3 domainMigrateFinish3;
+ virDrvDomainMigrateConfirm3 domainMigrateConfirm3;
};
typedef int
diff --git a/src/libvirt.c b/src/libvirt.c
index e24fb9e..04a7cd0 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3342,6 +3342,22 @@ error:
}
+/*
+ * Sequence v1:
+ *
+ * Dst: Prepare
+ * - Get ready to accept incoming VM
+ * - Generate optional cookie to pass to src
+ *
+ * Src: Perform
+ * - Start migration and wait for send completion
+ * - Kill off VM if successful, resume if failed
+ *
+ * Dst: Finish
+ * - Wait for recv completion and check status
+ * - Kill off VM if unsuccessful
+ *
+ */
static virDomainPtr
virDomainMigrateVersion1 (virDomainPtr domain,
virConnectPtr dconn,
@@ -3411,6 +3427,25 @@ virDomainMigrateVersion1 (virDomainPtr domain,
return ddomain;
}
+/*
+ * Sequence v2:
+ *
+ * Src: DumpXML
+ * - Generate XML to pass to dst
+ *
+ * Dst: Prepare
+ * - Get ready to accept incoming VM
+ * - Generate optional cookie to pass to src
+ *
+ * Src: Perform
+ * - Start migration and wait for send completion
+ * - Kill off VM if successful, resume if failed
+ *
+ * Dst: Finish
+ * - Wait for recv completion and check status
+ * - Kill off VM if unsuccessful
+ *
+ */
static virDomainPtr
virDomainMigrateVersion2 (virDomainPtr domain,
virConnectPtr dconn,
@@ -3505,6 +3540,130 @@ virDomainMigrateVersion2 (virDomainPtr domain,
}
+/*
+ * Sequence v3:
+ *
+ * Src: Begin
+ * - Generate XML to pass to dst
+ * - Generate optional cookie to pass to dst
+ *
+ * Dst: Prepare
+ * - Get ready to accept incoming VM
+ * - Generate optional cookie to pass to src
+ *
+ * Src: Perform
+ * - Start migration and wait for send completion
+ * - Generate optional cookie to pass to dst
+ *
+ * Dst: Finish
+ * - Wait for recv completion and check status
+ * - Kill off VM if failed, resume if success
+ * - Generate optional cookie to pass to src
+ *
+ * Src: Confirm
+ * - Kill off VM if success, resume if failed
+ *
+ */
+static virDomainPtr
+virDomainMigrateVersion3 (virDomainPtr domain,
+ virConnectPtr dconn,
+ unsigned long flags,
+ const char *dname,
+ const char *uri,
+ unsigned long bandwidth)
+{
+ virDomainPtr ddomain = NULL;
+ char *uri_out = NULL;
+ char *cookiesrc = NULL;
+ char *cookiedst = NULL;
+ char *dom_xml = NULL;
+ int cookiesrclen = 0;
+ int cookiedstlen = 0;
+ int ret;
+ virDomainInfo info;
+ virErrorPtr orig_err = NULL;
+
+ if (!domain->conn->driver->domainMigrateBegin3) {
+ virLibConnError (domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
+ virDispatchError(domain->conn);
+ return NULL;
+ }
+ dom_xml = domain->conn->driver->domainMigrateBegin3
+ (domain->conn, &cookiesrc, &cookiesrclen, uri, flags, dname,
+ bandwidth);
+ if (!dom_xml)
+ goto done;
+
+ ret = virDomainGetInfo (domain, &info);
+ if (ret == 0 && info.state == VIR_DOMAIN_PAUSED) {
+ flags |= VIR_MIGRATE_PAUSED;
+ }
+
+ ret = dconn->driver->domainMigratePrepare3
+ (dconn, cookiesrc, cookiesrclen, &cookiedst, &cookiedstlen,
+ uri, &uri_out, flags, dname, bandwidth, dom_xml);
+ VIR_FREE (dom_xml);
+ if (ret == -1)
+ goto done;
+
+ if (uri == NULL && uri_out == NULL) {
+ virLibConnError (domain->conn, VIR_ERR_INTERNAL_ERROR,
+ _("domainMigratePrepare2 did not set uri"));
+ virDispatchError(domain->conn);
+ goto done;
+ }
+ if (uri_out)
+ uri = uri_out; /* Did domainMigratePrepare2 change URI? */
+ assert (uri != NULL);
+
+ /* Perform the migration. The driver isn't supposed to return
+ * until the migration is complete. The src VM should remain
+ * running, but in paused state until the destination can
+ * confirm migration completion.
+ */
+ ret = domain->conn->driver->domainMigratePerform3
+ (domain, &cookiesrc, &cookiesrclen, cookiedst, cookiedstlen,
+ uri, flags, dname, bandwidth);
+
+ /* Perform failed. Make sure Finish doesn't overwrite the error */
+ if (ret < 0)
+ orig_err = virSaveLastError();
+
+ /*
+ * The status code from the source is passed to the destination.
+ * The dest can cleanup in the source indicated it failed to
+ * send all migration data. Returns NULL for ddomain if
+ * the dest was unable to complete migration.
+ */
+ dname = dname ? dname : domain->name;
+ ddomain = dconn->driver->domainMigrateFinish3
+ (dconn, dname, cookiesrc, cookiesrclen, &cookiedst, &cookiedstlen,
+ uri, flags, ret);
+
+ /*
+ * If Perform3 indicated an error, or if NULL was returned
+ * from Finish3, then the status code tells the source
+ * to resume CPUs on the original VM.
+ */
+ ret = domain->conn->driver->domainMigrateConfirm3
+ (domain->conn, dname, cookiesrc, cookiesrclen, cookiedst, cookiedstlen,
+ uri, flags, ret >= 0 && domain ? 0 : -1);
+ /* XXX is there anything we can do if Confirm3 returns -1.
+ * Probably nothing beyond praying
+ */
+
+ done:
+ if (orig_err) {
+ virSetError(orig_err);
+ virFreeError(orig_err);
+ }
+ VIR_FREE(uri_out);
+ VIR_FREE(cookiesrc);
+ VIR_FREE(cookiedst);
+ return ddomain;
+}
+
+
/*
* This is sort of a migration v3
*
@@ -3716,6 +3875,11 @@ virDomainMigrate (virDomainPtr domain,
VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
VIR_DRV_FEATURE_MIGRATION_V2))
ddomain = virDomainMigrateVersion2(domain, dconn, flags, dname, uri, bandwidth);
+ else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
+ VIR_DRV_FEATURE_MIGRATION_V3) &&
+ VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
+ VIR_DRV_FEATURE_MIGRATION_V3))
+ ddomain = virDomainMigrateVersion3(domain, dconn, flags, dname, uri, bandwidth);
else {
/* This driver does not support any migration method */
virLibConnError(domain->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 1c4fa4f..d781d6b 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -66,6 +66,13 @@ enum {
* perform step is used.
*/
VIR_DRV_FEATURE_MIGRATION_DIRECT = 5,
+
+ /*
+ * Driver supports V3-style virDomainMigrate, ie domainMigrateBegin3/
+ * domainMigratePrepare3/domainMigratePerform3/domainMigrateFinish3/
+ * domainMigrateConfirm3.
+ */
+ VIR_DRV_FEATURE_MIGRATION_V3 = 6,
};
--
1.7.2.3
13 years, 11 months
[libvirt] [PATCH] tests: avoid spurious failure of nodeinfotest
by Eric Blake
When running 'make check' under a multi-cpu Dom0 xen machine,
nodeinfotest had a spurious failure it was reading from
/sys/devices/system/cpu, but xen has no notion of topology. The test
was intended to be isolated from reading any real system files; the
regression was introduced in Mar 2010 with commit aa2f6f96dd.
Fix things by allowing an early exit for the testsuite.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Add parameter.
(nodeGetInfo): Adjust caller.
* tests/nodeinfotest.c (linuxTestCompareFiles): Likewise.
---
src/nodeinfo.c | 11 ++++++++---
tests/nodeinfotest.c | 5 +++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index acd3188..22d53e5 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -61,7 +61,8 @@
/* NB, this is not static as we need to call it from the testsuite */
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
- virNodeInfoPtr nodeinfo);
+ virNodeInfoPtr nodeinfo,
+ bool need_hyperthreads);
/* Return the positive decimal contents of the given
* CPU_SYS_PATH/cpu%u/FILE, or -1 on error. If MISSING_OK and the
@@ -167,7 +168,8 @@ static int parse_socket(unsigned int cpu)
}
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
- virNodeInfoPtr nodeinfo)
+ virNodeInfoPtr nodeinfo,
+ bool need_hyperthreads)
{
char line[1024];
DIR *cpudir = NULL;
@@ -244,6 +246,9 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
return -1;
}
+ if (!need_hyperthreads)
+ return 0;
+
/* OK, we've parsed what we can out of /proc/cpuinfo. Get the socket
* and thread information from /sys
*/
@@ -338,7 +343,7 @@ int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) {
_("cannot open %s"), CPUINFO_PATH);
return -1;
}
- ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo);
+ ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo, true);
VIR_FORCE_FCLOSE(cpuinfo);
if (ret < 0)
return -1;
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index f56247b..c690403 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -26,7 +26,8 @@ static char *abs_srcdir;
# define MAX_FILE 4096
-extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo);
+extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo,
+ bool need_hyperthreads);
static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) {
char actualData[MAX_FILE];
@@ -43,7 +44,7 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
return -1;
memset(&nodeinfo, 0, sizeof(nodeinfo));
- if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo) < 0) {
+ if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo, false) < 0) {
if (virTestGetDebug()) {
virErrorPtr error = virSaveLastError();
if (error && error->code != VIR_ERR_OK)
--
1.7.3.3
13 years, 11 months