[libvirt] [PATCH] spice: expose the disable file transfer option
by Francesco Romani
spice-server offers an API to disable file transfer messages
on the agent channel between the client and the guest.
This is supported in qemu through the disable-agent-file-xfer option.
This patch exposes this option to libvirt.
---
src/conf/domain_conf.c | 26 ++++++++++++++++++++++++++
src/conf/domain_conf.h | 10 ++++++++++
src/libvirt_private.syms | 2 ++
src/qemu/qemu_command.c | 2 ++
4 files changed, 40 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e65f3e3..5483a91 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -604,6 +604,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpiceClipboardCopypaste,
"yes",
"no");
+VIR_ENUM_IMPL(virDomainGraphicsSpiceAgentFileTransfer,
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_LAST,
+ "default",
+ "yes",
+ "no");
+
VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
"subsystem",
"capabilities")
@@ -8519,6 +8525,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
VIR_FREE(copypaste);
def->data.spice.copypaste = copypasteVal;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "filetransfer")) {
+ char *enable = virXMLPropString(cur, "enabled");
+ int enableVal;
+
+ if (!enable) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("spice filetransfer missing enable"));
+ goto error;
+ }
+
+ if ((enableVal =
+ virDomainGraphicsSpiceAgentFileTransferTypeFromString(enable)) <= 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown enable value '%s'"), enable);
+ VIR_FREE(enable);
+ goto error;
+ }
+ VIR_FREE(enable);
+
+ def->data.spice.filetransfer = enableVal;
} else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) {
char *mode = virXMLPropString(cur, "mode");
int modeVal;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 647d115..ce877fc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1461,6 +1461,14 @@ enum virDomainGraphicsSpiceClipboardCopypaste {
VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_LAST
};
+enum virDomainGraphicsSpiceAgentFileTransfer {
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_YES,
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_NO,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_LAST
+};
+
enum virDomainGraphicsListenType {
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
@@ -1531,6 +1539,7 @@ struct _virDomainGraphicsDef {
int playback;
int streaming;
int copypaste;
+ int filetransfer;
} spice;
} data;
/* nListens, listens, and *port are only useful if type is vnc,
@@ -2693,6 +2702,7 @@ VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
VIR_ENUM_DECL(virDomainGraphicsListen)
VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
+VIR_ENUM_DECL(virDomainGraphicsSpiceAgentFileTransfer)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2dbb8f8..cafcb84 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -235,6 +235,8 @@ virDomainGraphicsListenGetType;
virDomainGraphicsListenSetAddress;
virDomainGraphicsListenSetNetwork;
virDomainGraphicsListenSetType;
+virDomainGraphicsSpiceAgentFileTransferTypeFromString;
+virDomainGraphicsSpiceAgentFileTransferTypeToString;
virDomainGraphicsSpiceChannelModeTypeFromString;
virDomainGraphicsSpiceChannelModeTypeToString;
virDomainGraphicsSpiceChannelNameTypeFromString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d723dc8..e370853 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7394,6 +7394,8 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
virDomainGraphicsSpiceStreamingModeTypeToString(graphics->data.spice.streaming));
if (graphics->data.spice.copypaste == VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_NO)
virBufferAddLit(&opt, ",disable-copy-paste");
+ if (graphics->data.spice.filetransfer == VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_NO)
+ virBufferAddLit(&opt, ",disable-agent-file-xfer");
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) {
/* If qemu supports seamless migration turn it
--
1.8.4.2
10 years, 10 months
[libvirt] error in compiling event-test.c
by rash g
Hello,
I am trying to run event-test.c provided in libvirt package.I
am using ubuntu 13.04.
However,after compiling I am getting an error saying ->undefined
reference to...
I think this is because compiler is not able to find the functions and
macros in the header files.However I am not able to solve the problem.
I have provided my screenshot of error as an attachment. I
shall be really grateful if anyone can help me.
Thanks
Rashmi
10 years, 10 months
[libvirt] [PATCHv2] Fix explicit usage of default video PCI slots
by Ján Tomko
Do not leave the PCI address of the primary video card set
to the legacy default (0000:00:02.0) if we're doing two-pass
allocation.
Since QEMU 1.6 (QEMU_CAPS_VIDEO_PRIMARY) we allow the primary
video card to be on other slots than 0000:00:02.0 (as we use
-device instead of -vga).
However we fail to assign it an address if:
* another device explicitly uses 0000:00:02.0 and
* the primary video device has no address specified
On the first pass, we have set the address to default, then checked
if it's available, leaving it set even if it wasn't. This address
got picked up by the second pass, resulting in a conflict:
XML error: Attempted double use of PCI slot 0000:00:02.0
(may need "multifunction='on'" for device on function 0)
Also fix the test that was supposed to catch this.
---
v1: https://www.redhat.com/archives/libvir-list/2013-December/msg01125.html
v2: no functional change
rewrote the commit message to mention that this only happens
with QEMU 1.6 and (hopefully) explain what 'this' is more clearly
src/qemu/qemu_command.c | 50 +++++++++++++++++++++---------------------------
tests/qemuxml2argvtest.c | 3 ++-
2 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d723dc8..2a64cd1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2379,7 +2379,6 @@ qemuValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
size_t i;
virDevicePCIAddress tmp_addr;
bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
- virDevicePCIAddressPtr addrptr;
char *addrStr = NULL;
qemuDomainPCIConnectFlags flags = QEMU_PCI_CONNECT_HOTPLUGGABLE | QEMU_PCI_CONNECT_TYPE_PCI;
@@ -2446,22 +2445,17 @@ qemuValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
*/
virDomainVideoDefPtr primaryVideo = def->videos[0];
if (primaryVideo->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
- primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
- primaryVideo->info.addr.pci.domain = 0;
- primaryVideo->info.addr.pci.bus = 0;
- primaryVideo->info.addr.pci.slot = 2;
- primaryVideo->info.addr.pci.function = 0;
- addrptr = &primaryVideo->info.addr.pci;
-
- if (!(addrStr = qemuDomainPCIAddressAsString(addrptr)))
+ memset(&tmp_addr, 0, sizeof(tmp_addr));
+ tmp_addr.slot = 2;
+
+ if (!(addrStr = qemuDomainPCIAddressAsString(&tmp_addr)))
goto cleanup;
- if (!qemuDomainPCIAddressValidate(addrs, addrptr,
+ if (!qemuDomainPCIAddressValidate(addrs, &tmp_addr,
addrStr, flags, false))
goto cleanup;
- if (qemuDomainPCIAddressSlotInUse(addrs, addrptr)) {
+ if (qemuDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
if (qemuDeviceVideoUsable) {
- virResetLastError();
if (qemuDomainPCIAddressReserveNextSlot(addrs,
&primaryVideo->info,
flags) < 0)
@@ -2472,8 +2466,11 @@ qemuValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
"QEMU needs it for primary video"));
goto cleanup;
}
- } else if (qemuDomainPCIAddressReserveSlot(addrs, addrptr, flags) < 0) {
- goto cleanup;
+ } else {
+ if (qemuDomainPCIAddressReserveSlot(addrs, &tmp_addr, flags) < 0)
+ goto cleanup;
+ primaryVideo->info.addr.pci = tmp_addr;
+ primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
}
} else if (!qemuDeviceVideoUsable) {
if (primaryVideo->info.addr.pci.domain != 0 ||
@@ -2535,7 +2532,6 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
size_t i;
virDevicePCIAddress tmp_addr;
bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
- virDevicePCIAddressPtr addrptr;
char *addrStr = NULL;
qemuDomainPCIConnectFlags flags = QEMU_PCI_CONNECT_TYPE_PCIE;
@@ -2619,22 +2615,17 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
*/
virDomainVideoDefPtr primaryVideo = def->videos[0];
if (primaryVideo->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
- primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
- primaryVideo->info.addr.pci.domain = 0;
- primaryVideo->info.addr.pci.bus = 0;
- primaryVideo->info.addr.pci.slot = 1;
- primaryVideo->info.addr.pci.function = 0;
- addrptr = &primaryVideo->info.addr.pci;
-
- if (!(addrStr = qemuDomainPCIAddressAsString(addrptr)))
+ memset(&tmp_addr, 0, sizeof(tmp_addr));
+ tmp_addr.slot = 1;
+
+ if (!(addrStr = qemuDomainPCIAddressAsString(&tmp_addr)))
goto cleanup;
- if (!qemuDomainPCIAddressValidate(addrs, addrptr,
+ if (!qemuDomainPCIAddressValidate(addrs, &tmp_addr,
addrStr, flags, false))
goto cleanup;
- if (qemuDomainPCIAddressSlotInUse(addrs, addrptr)) {
+ if (qemuDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
if (qemuDeviceVideoUsable) {
- virResetLastError();
if (qemuDomainPCIAddressReserveNextSlot(addrs,
&primaryVideo->info,
flags) < 0)
@@ -2645,8 +2636,11 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
"QEMU needs it for primary video"));
goto cleanup;
}
- } else if (qemuDomainPCIAddressReserveSlot(addrs, addrptr, flags) < 0) {
- goto cleanup;
+ } else {
+ if (qemuDomainPCIAddressReserveSlot(addrs, &tmp_addr, flags) < 0)
+ goto cleanup;
+ primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+ primaryVideo->info.addr.pci = tmp_addr;
}
} else if (!qemuDeviceVideoUsable) {
if (primaryVideo->info.addr.pci.domain != 0 ||
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 847e96f..5a2bfcc 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1193,7 +1193,8 @@ mymain(void)
DO_TEST("video-device-pciaddr-default",
QEMU_CAPS_KVM, QEMU_CAPS_VNC,
QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
- QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA);
+ QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA,
+ QEMU_CAPS_DEVICE_PCI_BRIDGE);
DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_RANDOM);
--
1.8.3.2
10 years, 10 months
[libvirt] [PATCH] Support transient attribute on vmware disks
by Wout Mertens
From: Wout Mertens <Wout.Mertens(a)gmail.com>
vmx/vmx.c ignores the transient attribute on the disk xml format. This patch
adds a 1-1 relationship between it and [disk].mode = "independent-nonpersistent".
The other modes are ignored as before. It works in my testing.
https://bugzilla.redhat.com/show_bug.cgi?id=1044023
---
src/vmx/vmx.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 48487f8..4282390 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1954,6 +1954,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
* busType = VIR_DOMAIN_DISK_BUS_FDC
* controllerOrBus = [0]
* unit = [0..1]
+ *
*/
int result = -1;
@@ -1980,6 +1981,9 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
char writeThrough_name[32] = "";
bool writeThrough = false;
+ char mode_name[32] = "";
+ char *mode = NULL;
+
if (def == NULL || *def != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
@@ -2093,6 +2097,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
VMX_BUILD_NAME(fileType);
VMX_BUILD_NAME(fileName);
VMX_BUILD_NAME(writeThrough);
+ VMX_BUILD_NAME(mode);
/* vmx:present */
if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) {
@@ -2121,6 +2126,11 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
goto cleanup;
}
+ /* vmx:mode -> def:transient */
+ if (virVMXGetConfigString(conf, mode_name, &mode, true) < 0) {
+ goto cleanup;
+ }
+
if (clientDevice) {
/*
* Just ignore devices in client mode, because I have no clue how to
@@ -2172,6 +2182,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
(*def)->src = ctx->parseFileName(fileName, ctx->opaque);
(*def)->cachemode = writeThrough ? VIR_DOMAIN_DISK_CACHE_WRITETHRU
: VIR_DOMAIN_DISK_CACHE_DEFAULT;
+ (*def)->transient = STRCASEEQ(mode, "independent-nonpersistent") ? true: false;
if ((*def)->src == NULL) {
goto cleanup;
@@ -3497,7 +3508,11 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
return -1;
}
}
-
+
+ if (def->transient) {
+ virBufferAsprintf(buffer, "%s%d:%d.mode = \"independent-nonpersistent\"\n",
+ busType, controllerOrBus, unit);
+ }
return 0;
}
--
1.8.2.3
10 years, 10 months
[libvirt] event detection in kvm
by rash g
Hello,
I am student and doing a project in virtualization.My project
requires detection of events in kvm like start of a virtual machine,shutoff
of a virtual machine.
So I want to know if there is any way by which I can detect these
events.As in I want to write a code which will detect these events and then
handle them.I am using ubuntu 13.04.
I would be glad if anyone can help me.
Thanks
Rashmi
10 years, 10 months
[libvirt] detection of events in kvm
by rash
Hello,
I am student and doing a project in virtualization.My project requires
detection of events in kvm like start of a virtual machine,shutoff of a
virtual machine.
So I want to know if there is any way by which I can detect these
events.As in I want to write a code which will detect these events and then
handle them.I am using ubuntu 13.04.
I would be glad if anyone can help me.
Thanks
10 years, 10 months
[libvirt] [PATCH] vmware: os x support is broken
by Denis Kondratenko
Incorrect usage of virAsprintf and vmware-vmx reports to stderr.
--- https://bugzilla.redhat.com/show_bug.cgi?id=1036248
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index 027e245..477dc72 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -271,17 +271,17 @@ vmwareExtractVersion(struct vmware_driver *driver)
switch (driver->type) {
case VMWARE_DRIVER_PLAYER:
- if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmplayer"))
+ if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmplayer") < 0)
goto cleanup;
break;
case VMWARE_DRIVER_WORKSTATION:
- if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware"))
+ if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware") < 0)
goto cleanup;
break;
case VMWARE_DRIVER_FUSION:
- if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware-vmx"))
+ if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware-vmx") < 0)
goto cleanup;
break;
@@ -293,6 +293,9 @@ vmwareExtractVersion(struct vmware_driver *driver)
cmd = virCommandNewArgList(bin, "-v", NULL);
virCommandSetOutputBuffer(cmd, &outbuf);
+
+ // OS X 10.9.1 and some earlier ver: vmware-vmx reports ver to stderr
+ virCommandSetErrorBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
10 years, 10 months
[libvirt] ANNOUNCE: Oz 0.12.0 release
by Chris Lalancette
All,
I'm pleased to announce release 0.12.0 of Oz. Oz is a program for
doing automated installation of guest operating systems with limited
input from the user. Release 0.12.0 is a bugfix and feature release
for Oz. Some of the highlights between Oz 0.11.0 and 0.12.0 are:
* Fixes to concurrent oz-install invocations
* Python 3 compatibility in the test suites
* Support for Ubuntu 12.04.3
* Support for Mageia
* Allow a MAC address to be passed in (instead of auto-generated)
* Support for RHEL5.10
* Support for Ubuntu 13.10
* Use lxml instead of libxml2 for XML document processing (it has much
better error messages)
* Remove the unused "tunnels" functionality
* Support FreeBSD 10.0
* Remove deprecated functions from the Guest class
* Speed up guest customization on guests that support NetworkManager
* Follow subprocess commands as they are executed (makes debugging easier)
* Ensure that any paths from the user are absolute, otherwise things
don't work properly
* Add support for OpenSUSE 13.1
* Add support for Fedora 20
* Add support for RHEL-7
A tarball and zipfile of this release is available on the Github
releases page: https://github.com/clalancette/oz/releases . Packages
for Fedora-19, Fedora-20, and EPEL-6 have been built in Koji and will
eventually make their way to stable. Instructions on how to get and
use Oz are available at http://github.com/clalancette/oz/wiki .
If you have questions or comments about Oz, please feel free to
contact me at clalancette at gmail.com, or open up an issue on the
github page: http://github.com/clalancette/oz/issues .
Thanks to everyone who contributed to this release through bug
reports, patches, and suggestions for improvement.
Chris Lalancette
10 years, 10 months
[libvirt] [PATCH v2] BSD: implement nodeGetMemoryStats
by Roman Bogorodskiy
Add a BSD implementation of nodeGetMemoryStats based
on sysctl(3).
---
src/nodeinfo.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 79 insertions(+), 1 deletion(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 1838547..5e84e78 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -55,6 +55,8 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#if defined(__FreeBSD__) || defined(__APPLE__)
+# define BSD_MEMORY_STATS_ALL 4
+
static int
appleFreebsdNodeGetCPUCount(void)
{
@@ -96,7 +98,81 @@ appleFreebsdNodeGetMemorySize(unsigned long *memory)
return 0;
}
-#endif
+
+static int
+appleFreebsdNodeGetMemoryStats(virNodeMemoryStatsPtr params,
+ int *nparams)
+{
+ size_t i, j = 0;
+ unsigned long pagesize = getpagesize() >> 10;
+ long bufpages;
+ size_t bufpages_size = sizeof(bufpages);
+ struct field_sysctl_map {
+ const char *field;
+ const char *sysctl_name;
+ } sysctl_map[] = {
+ {VIR_NODE_MEMORY_STATS_TOTAL, "vm.stats.vm.v_page_count"},
+ {VIR_NODE_MEMORY_STATS_FREE, "vm.stats.vm.v_free_count"},
+ {VIR_NODE_MEMORY_STATS_CACHED, "vm.stats.vm.v_cache_count"},
+ {NULL, NULL}
+ };
+
+ if ((*nparams) == 0) {
+ *nparams = BSD_MEMORY_STATS_ALL;
+ return 0;
+ }
+
+ if ((*nparams) != BSD_MEMORY_STATS_ALL) {
+ virReportInvalidArg(nparams,
+ _("nparams in %s must be %d"),
+ __FUNCTION__, BSD_MEMORY_STATS_ALL);
+ return -1;
+ }
+
+ for (i = 0; sysctl_map[i].field != NULL; i++) {
+ u_int value;
+ size_t value_size = sizeof(value);
+ virNodeMemoryStatsPtr param;
+
+ if (sysctlbyname(sysctl_map[i].sysctl_name, &value,
+ &value_size, NULL, 0) < 0) {
+ virReportSystemError(errno,
+ _("sysctl failed for '%s'"),
+ sysctl_map[i].sysctl_name);
+ return -1;
+ }
+
+ param = ¶ms[j++];
+ if (virStrcpyStatic(param->field, sysctl_map[i].field) == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field '%s' too long for destination"),
+ sysctl_map[i].field);
+ return -1;
+ }
+ param->value = (unsigned long long)value * pagesize;
+ }
+
+ {
+ virNodeMemoryStatsPtr param = ¶ms[j++];
+
+ if (sysctlbyname("vfs.bufspace", &bufpages, &bufpages_size, NULL, 0) < 0) {
+ virReportSystemError(errno,
+ _("sysctl failed for '%s'"),
+ "vfs.bufspace");
+ return -1;
+ }
+ if (virStrcpyStatic(param->field, VIR_NODE_MEMORY_STATS_BUFFERS) == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Field '%s' too long for destination"),
+ VIR_NODE_MEMORY_STATS_BUFFERS);
+ return -1;
+ }
+ param->value = (unsigned long long)bufpages >> 10;
+ }
+
+ return 0;
+}
+#endif /* defined(__FreeBSD__) || defined(__APPLE__) */
#ifdef __linux__
# define CPUINFO_PATH "/proc/cpuinfo"
@@ -1041,6 +1117,8 @@ int nodeGetMemoryStats(int cellNum ATTRIBUTE_UNUSED,
return ret;
}
+#elif defined(__FreeBSD__) || defined(__APPLE__)
+ return appleFreebsdNodeGetMemoryStats(params, nparams);
#else
virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("node memory stats not implemented on this platform"));
--
1.8.4.3
10 years, 10 months