[libvirt] [PATCH] security_manager: fix comparison
by Guido Günther
otherwise we crash later on if we don't find a match like:
#0 0xb72c2b4f in virSecurityManagerGenLabel (mgr=0xb8e42d20, vm=0xb8ef40c0) at security/security_manager.c:424
#1 0xb18811f3 in qemuProcessStart (conn=conn@entry=0xb8eed880, driver=driver@entry=0xb8e3b1e0, vm=vm@entry=0xb8ef58f0,
migrateFrom=migrateFrom@entry=0xb18f6088 "stdio", stdin_fd=18,
stdin_path=stdin_path@entry=0xb8ea7798 "/var/lib/jenkins/jobs/libvirt-tck-build/workspace/tck.img", snapshot=snapshot@entry=0x0,
vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, flags=flags@entry=2) at qemu/qemu_process.c:3364
#2 0xb18d6cb2 in qemuDomainSaveImageStartVM (conn=conn@entry=0xb8eed880, driver=driver@entry=0xb8e3b1e0, vm=0xb8ef58f0, fd=fd@entry=0xb6bf3f98,
header=header@entry=0xb6bf3fa0, path=path@entry=0xb8ea7798 "/var/lib/jenkins/jobs/libvirt-tck-build/workspace/tck.img",
start_paused=start_paused@entry=false) at qemu/qemu_driver.c:4843
#3 0xb18d7eeb in qemuDomainRestoreFlags (conn=conn@entry=0xb8eed880,
path=path@entry=0xb8ea7798 "/var/lib/jenkins/jobs/libvirt-tck-build/workspace/tck.img", dxml=dxml@entry=0x0, flags=flags@entry=0)
at qemu/qemu_driver.c:4962
#4 0xb18d8123 in qemuDomainRestore (conn=0xb8eed880, path=0xb8ea7798 "/var/lib/jenkins/jobs/libvirt-tck-build/workspace/tck.img")
at qemu/qemu_driver.c:4987
#5 0xb718d186 in virDomainRestore (conn=0xb8eed880, from=0xb8ea87d8 "/var/lib/jenkins/jobs/libvirt-tck-build/workspace/tck.img") at libvirt.c:2768
#6 0xb7736363 in remoteDispatchDomainRestore (args=<optimized out>, rerr=0xb6bf41f0, client=0xb8eedaf0, server=<optimized out>, msg=<optimized out>)
at remote_dispatch.h:4679
#7 remoteDispatchDomainRestoreHelper (server=0xb8e1a3e0, client=0xb8eedaf0, msg=0xb8ee72c8, rerr=0xb6bf41f0, args=0xb8ea8968, ret=0xb8ef5330)
at remote_dispatch.h:4661
#8 0xb720db01 in virNetServerProgramDispatchCall (msg=0xb8ee72c8, client=0xb8eedaf0, server=0xb8e1a3e0, prog=0xb8e216b0)
at rpc/virnetserverprogram.c:439
#9 virNetServerProgramDispatch (prog=0xb8e216b0, server=server@entry=0xb8e1a3e0, client=0xb8eedaf0, msg=0xb8ee72c8) at rpc/virnetserverprogram.c:305
#10 0xb7206e97 in virNetServerProcessMsg (msg=<optimized out>, prog=<optimized out>, client=<optimized out>, srv=0xb8e1a3e0) at rpc/virnetserver.c:162
#11 virNetServerHandleJob (jobOpaque=0xb8ea7720, opaque=0xb8e1a3e0) at rpc/virnetserver.c:183
#12 0xb70f9f78 in virThreadPoolWorker (opaque=opaque@entry=0xb8e1a540) at util/virthreadpool.c:144
#13 0xb70f94a5 in virThreadHelper (data=0xb8e0e558) at util/virthreadpthread.c:161
#14 0xb705d954 in start_thread (arg=0xb6bf4b70) at pthread_create.c:304
#15 0xb6fd595e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
This unbreaks libvirt-tck's domain/100-transient-save-restore.t with
qemu:///session and selinux compiled in but disabled.
Introduced by 8d68cbeaa8a64759323da1d64526e2a941eb93e1
---
src/security/security_manager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
index 757fe28..f7c5c2e 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -437,7 +437,7 @@ int virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
return ret;
virObjectLock(mgr);
- for (i = 0; vm->nseclabels; i++) {
+ for (i = 0; i < vm->nseclabels; i++) {
for (j = 0; sec_managers[j]; j++)
if (STREQ(vm->seclabels[i]->model, sec_managers[j]->drv->name))
break;
--
1.7.10.4
11 years, 7 months
[libvirt] [PATCH] Create fake NUMA info if libnuma isn't available
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If libnuma is not compiled in, or numa_available() returns an
error, stub out fake NUMA info consisting of one NUMA cell
containing all CPUs and memory.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/nodeinfo.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 111 insertions(+), 26 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 72ab394..34d9410 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -1467,6 +1467,97 @@ cleanup:
return ret;
}
+static int
+nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
+{
+ virNodeInfo nodeinfo;
+ virCapsHostNUMACellCPUPtr cpus;
+ int ncpus;
+ int s, c, t;
+ int id;
+
+ if (nodeGetInfo(NULL, &nodeinfo) < 0)
+ return -1;
+
+ ncpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
+
+ if (VIR_ALLOC_N(cpus, ncpus) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ id = 0;
+ for (s = 0 ; s < nodeinfo.sockets ; s++) {
+ for (c = 0 ; c < nodeinfo.cores ; c++) {
+ for (t = 0 ; t < nodeinfo.threads ; t++) {
+ cpus[id].id = id;
+ cpus[id].socket_id = s;
+ cpus[id].core_id = c;
+ if (!(cpus[id].siblings = virBitmapNew(ncpus)))
+ goto error;
+ if (virBitmapSetBit(cpus[id].siblings, id) < 0)
+ goto error;
+ id++;
+ }
+ }
+ }
+
+ if (virCapabilitiesAddHostNUMACell(caps, 0,
+ ncpus,
+ nodeinfo.memory,
+ cpus) < 0)
+ goto error;
+
+ return 0;
+
+ error:
+ for ( ; id >= 0 ; id--)
+ virBitmapFree(cpus[id].siblings);
+ VIR_FREE(cpus);
+ return -1;
+}
+
+static int
+nodeGetCellsFreeMemoryFake(virConnectPtr conn ATTRIBUTE_UNUSED,
+ unsigned long long *freeMems,
+ int startCell,
+ int maxCells ATTRIBUTE_UNUSED)
+{
+ double avail = physmem_available();
+
+ if (startCell != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("start cell %d out of range (0-%d)"),
+ startCell, 0);
+ return -1;
+ }
+
+ freeMems[0] = (unsigned long long)avail;
+
+ if (!freeMems[0]) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot determine free memory"));
+ return -1;
+ }
+
+ return 1;
+}
+
+static unsigned long long
+nodeGetFreeMemoryFake(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ double avail = physmem_available();
+ unsigned long long ret;
+
+ if (!(ret = (unsigned long long)avail)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot determine free memory"));
+ return 0;
+ }
+
+ return ret;
+}
+
#if WITH_NUMACTL
# if LIBNUMA_API_VERSION <= 1
# define NUMA_MAX_N_CPUS 4096
@@ -1547,7 +1638,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
bool topology_failed = false;
if (numa_available() < 0)
- return 0;
+ return nodeCapsInitNUMAFake(caps);
int mask_n_bytes = max_n_cpus / 8;
if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0)
@@ -1610,7 +1701,7 @@ cleanup:
int
-nodeGetCellsFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED,
+nodeGetCellsFreeMemory(virConnectPtr conn,
unsigned long long *freeMems,
int startCell,
int maxCells)
@@ -1619,11 +1710,10 @@ nodeGetCellsFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED,
int ret = -1;
int maxCell;
- if (numa_available() < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("NUMA not supported on this host"));
- goto cleanup;
- }
+ if (numa_available() < 0)
+ return nodeGetCellsFreeMemoryFake(conn, freeMems,
+ startCell, maxCells);
+
maxCell = numa_max_node();
if (startCell > maxCell) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1652,16 +1742,14 @@ cleanup:
}
unsigned long long
-nodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
+nodeGetFreeMemory(virConnectPtr conn)
{
unsigned long long freeMem = 0;
int n;
- if (numa_available() < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("NUMA not supported on this host"));
- goto cleanup;
- }
+ if (numa_available() < 0)
+ return nodeGetFreeMemoryFake(conn);
+
for (n = 0 ; n <= numa_max_node() ; n++) {
long long mem;
@@ -1720,24 +1808,21 @@ cleanup:
#else
-int nodeCapsInitNUMA(virCapsPtr caps ATTRIBUTE_UNUSED) {
- return 0;
+int nodeCapsInitNUMA(virCapsPtr caps) {
+ return nodeCapsInitNUMAFake(caps);
}
-int nodeGetCellsFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED,
- unsigned long long *freeMems ATTRIBUTE_UNUSED,
- int startCell ATTRIBUTE_UNUSED,
- int maxCells ATTRIBUTE_UNUSED)
+int nodeGetCellsFreeMemory(virConnectPtr conn,
+ unsigned long long *freeMems,
+ int startCell,
+ int maxCells)
{
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
- _("NUMA memory information not available on this platform"));
- return -1;
+ return nodeGetCellsFreeMemoryFake(conn, freeMems,
+ startCell, maxCells);
}
-unsigned long long nodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
+unsigned long long nodeGetFreeMemory(virConnectPtr conn)
{
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
- _("NUMA memory information not available on this platform"));
- return 0;
+ return nodeGetFreeMemoryFake(conn);
}
#endif
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH] Cope with missing /sys/devices/system/cpu/cpu0/topology files
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Not all kernel builds have any entries under the location
/sys/devices/system/cpu/cpu0/topology. We already cope with
that being missing in some cases, but not all. Update the
code which looks for thread_siblings to cope with the missing
file
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/nodeinfo.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 415c2e5..72ab394 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -168,6 +168,12 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu)
pathfp = fopen(path, "r");
if (pathfp == NULL) {
+ /* If file doesn't exist, then pretend our only
+ * sibling is ourself */
+ if (errno == ENOENT) {
+ VIR_FREE(path);
+ return 1;
+ }
virReportSystemError(errno, _("cannot open %s"), path);
VIR_FREE(path);
return 0;
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH] Add armv6l architecture to list of valid arches
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The Raspberry Pi runs the armv6l architecture and apparently
people are trying to run libvirt LXC on it. So we should allow
that as a valid arch
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/util/virarch.c | 1 +
src/util/virarch.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/util/virarch.c b/src/util/virarch.c
index ffd07dc..8585a78 100644
--- a/src/util/virarch.c
+++ b/src/util/virarch.c
@@ -35,6 +35,7 @@ static const struct virArchData {
} virArchData[] = {
{ "none", 0, VIR_ARCH_LITTLE_ENDIAN },
{ "alpha", 64, VIR_ARCH_BIG_ENDIAN },
+ { "armv6l", 32, VIR_ARCH_LITTLE_ENDIAN },
{ "armv7l", 32, VIR_ARCH_LITTLE_ENDIAN },
{ "cris", 32, VIR_ARCH_LITTLE_ENDIAN },
{ "i686", 32, VIR_ARCH_LITTLE_ENDIAN },
diff --git a/src/util/virarch.h b/src/util/virarch.h
index 9cf6ce2..0d8ae25 100644
--- a/src/util/virarch.h
+++ b/src/util/virarch.h
@@ -27,6 +27,7 @@
typedef enum {
VIR_ARCH_NONE,
VIR_ARCH_ALPHA, /* Alpha 64 BE http://en.wikipedia.org/wiki/DEC_Alpha */
+ VIR_ARCH_ARMV6L, /* ARMv6 32 LE http://en.wikipedia.org/wiki/ARM_architecture */
VIR_ARCH_ARMV7L, /* ARMv7 32 LE http://en.wikipedia.org/wiki/ARM_architecture */
VIR_ARCH_CRIS, /* ETRAX 32 LE http://en.wikipedia.org/wiki/ETRAX_CRIS */
VIR_ARCH_I686, /* x86 32 LE http://en.wikipedia.org/wiki/X86 */
--
1.8.1.4
11 years, 7 months
[libvirt] libvirtd segfault on latest git
by Luiz Capitulino
Hi,
Libvirtd from latest git (HEAD fc8c1787) is segfaulting when I try to
restore a previously saved domain (backtrace below).
I was testing a custom QEMU when it happened first time, but it also
happens with latest qemu.git (HEAD 162cbbd17).
What I did to run libvirt from source was:
1. Build it
$ ./autogen.sh --system --enable-compile-warnings=error
$ ./configure --localstatedir=/var --sysconfdir=/etc --prefix=/usr --libdir=/usr/lib
(this was needed because I had to re-ran configure and it ended up overwriting
--system)
$ make -j4
2. Stop system's libvirtd
# systemctl stop libvitd
3. Change /etc/libvirt/qemu/Fedora18.xml to use a custom QEMU binary
4. Run libvirtd
# ./daemon/libvirtd
5. Reproduce the problem with virsh
# ./tools/virsh
virsh # save Fedora18 foobar
virsh # restore foobar
error: Failed to restore domain from foobar
error: End of file while reading data: Input/output error
error: Failed to reconnect to the hypervisor
6. Change to the libvirtd terminal
[...]
2013-04-03 20:01:58.742+0000: 32334: debug : virNetServerAddShutdownInhibition:795 : srv=0x1ecf3f0 inhibitions=1
2013-04-03 20:01:58.742+0000: 32334: debug : qemuProcessStart:3351 : Preparing host devices
2013-04-03 20:01:58.742+0000: 32334: debug : qemuProcessStart:3355 : Preparing chr devices
2013-04-03 20:01:58.742+0000: 32334: debug : qemuProcessStart:3364 : Generating domain security label (if required)
====== end of log =====
Segmentation fault (core dumped)
[root@doriath libvirt]#
Here's the backtrace:
Core was generated by `/home/lcapitulino/work/src/upstream/libvirt/daemon/.libs/lt-libvirtd'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f7623a4e79f in virSecurityManagerGenLabel (mgr=0x7f760c022380, vm=<optimized out>) at security/security_manager.c:424
424 int virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
(gdb) bt
#0 0x00007f7623a4e79f in virSecurityManagerGenLabel (mgr=0x7f760c022380, vm=<optimized out>) at security/security_manager.c:424
#1 0x00007f761467718c in qemuProcessStart (conn=conn@entry=0x7f7608000ad0, driver=driver@entry=0x7f760c009440,
vm=vm@entry=0x7f760c2097d0, migrateFrom=migrateFrom@entry=0x7f76146dfeeb "stdio", stdin_fd=16,
stdin_path=stdin_path@entry=0x7f7600000a90 "/home/lcapitulino/work/src/upstream/libvirt/foobar", snapshot=snapshot@entry=0x0,
vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, flags=flags@entry=2) at qemu/qemu_process.c:3365
#2 0x00007f76146c25a0 in qemuDomainSaveImageStartVM (conn=conn@entry=0x7f7608000ad0, driver=driver@entry=0x7f760c009440,
vm=vm@entry=0x7f760c2097d0, fd=fd@entry=0x7f761882fa7c, header=header@entry=0x7f761882fa90,
path=path@entry=0x7f7600000a90 "/home/lcapitulino/work/src/upstream/libvirt/foobar", start_paused=start_paused@entry=false)
at qemu/qemu_driver.c:4843
#3 0x00007f76146c35c6 in qemuDomainRestoreFlags (conn=0x7f7608000ad0,
path=0x7f7600000a90 "/home/lcapitulino/work/src/upstream/libvirt/foobar", dxml=<optimized out>, flags=<optimized out>)
at qemu/qemu_driver.c:4962
#4 0x00007f762393923b in virDomainRestore (conn=0x7f7608000ad0,
from=0x7f76000008c0 "/home/lcapitulino/work/src/upstream/libvirt/foobar") at libvirt.c:2768
#5 0x00007f7624365691 in remoteDispatchDomainRestore (server=<optimized out>, msg=<optimized out>, args=0x7f7600000900,
rerr=0x7f761882fcd0, client=0x7f76253b9150) at remote_dispatch.h:4679
#6 remoteDispatchDomainRestoreHelper (server=<optimized out>, client=0x7f76253b9150, msg=<optimized out>, rerr=0x7f761882fcd0,
args=0x7f7600000900, ret=<optimized out>) at remote_dispatch.h:4661
#7 0x00007f76239a4d56 in virNetServerProgramDispatchCall (msg=0x7f76253b8700, client=0x7f76253b9150, server=0x7f76253b23f0,
prog=0x7f76253bd070) at rpc/virnetserverprogram.c:439
#8 virNetServerProgramDispatch (prog=0x7f76253bd070, server=server@entry=0x7f76253b23f0, client=0x7f76253b9150, msg=0x7f76253b8700)
at rpc/virnetserverprogram.c:305
#9 0x00007f76239a0338 in virNetServerProcessMsg (msg=<optimized out>, prog=<optimized out>, client=<optimized out>,
srv=0x7f76253b23f0) at rpc/virnetserver.c:162
#10 virNetServerHandleJob (jobOpaque=<optimized out>, opaque=0x7f76253b23f0) at rpc/virnetserver.c:183
#11 0x00007f76238c20ee in virThreadPoolWorker (opaque=opaque@entry=0x7f76253bd230) at util/virthreadpool.c:144
#12 0x00007f76238c1766 in virThreadHelper (data=<optimized out>) at util/virthreadpthread.c:161
#13 0x00007f76227ffd15 in start_thread (arg=0x7f7618830700) at pthread_create.c:308
#14 0x00007f762212b48d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:114
11 years, 7 months
[libvirt] [PATCH] Implement minimal sysinfo for ARM platforms
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Implement the bare minimal sysinfo for ARM platforms by
reading the CPU models from /proc/cpuinfo
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/util/virsysinfo.c | 129 +++++++++++++++++++++++++++++++++++-
tests/sysinfodata/armcpuinfo.data | 17 +++++
tests/sysinfodata/armsysinfo.expect | 10 +++
tests/sysinfotest.c | 15 ++++-
4 files changed, 169 insertions(+), 2 deletions(-)
create mode 100644 tests/sysinfodata/armcpuinfo.data
create mode 100644 tests/sysinfodata/armsysinfo.expect
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index 83c445d..ba0c245 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -255,8 +255,134 @@ no_memory:
return NULL;
}
-#elif defined(__s390__) || defined(__s390x__)
+#elif defined(__arm__)
+static int
+virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret)
+{
+ char *eol = NULL;
+ const char *cur;
+
+ if ((cur = strstr(base, "platform")) == NULL)
+ return 0;
+
+ base = cur;
+ /* Account for format 'platform : XXXX'*/
+ cur = strchr(cur, ':') + 1;
+ eol = strchr(cur, '\n');
+ virSkipSpaces(&cur);
+ if (eol &&
+ ((ret->system_family = strndup(cur, eol - cur)) == NULL))
+ goto no_memory;
+
+ if ((cur = strstr(base, "model")) != NULL) {
+ cur = strchr(cur, ':') + 1;
+ eol = strchr(cur, '\n');
+ virSkipSpaces(&cur);
+ if (eol && ((ret->system_serial = strndup(cur, eol - cur))
+ == NULL))
+ goto no_memory;
+ }
+
+ if ((cur = strstr(base, "machine")) != NULL) {
+ cur = strchr(cur, ':') + 1;
+ eol = strchr(cur, '\n');
+ virSkipSpaces(&cur);
+ if (eol && ((ret->system_version = strndup(cur, eol - cur))
+ == NULL))
+ goto no_memory;
+ }
+ return 0;
+
+no_memory:
+ return -1;
+}
+
+static int
+virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
+{
+ const char *cur;
+ char *eol, *tmp_base;
+ virSysinfoProcessorDefPtr processor;
+ char *processor_type = NULL;
+
+ if (!(tmp_base = strstr(base, "Processor")))
+ return 0;
+
+ base = tmp_base;
+ eol = strchr(base, '\n');
+ cur = strchr(base, ':') + 1;
+ virSkipSpaces(&cur);
+ if (eol &&
+ ((processor_type = strndup(cur, eol - cur))
+ == NULL))
+ goto no_memory;
+ base = cur;
+
+ while ((tmp_base = strstr(base, "processor")) != NULL) {
+ base = tmp_base;
+ eol = strchr(base, '\n');
+ cur = strchr(base, ':') + 1;
+
+ if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
+ goto no_memory;
+ }
+ processor = &ret->processor[ret->nprocessor - 1];
+
+ virSkipSpaces(&cur);
+ if (eol &&
+ ((processor->processor_socket_destination = strndup
+ (cur, eol - cur)) == NULL))
+ goto no_memory;
+
+ if (processor_type &&
+ !(processor->processor_type = strdup(processor_type)))
+ goto no_memory;
+
+ base = cur;
+ }
+
+ VIR_FREE(processor_type);
+ return 0;
+
+no_memory:
+ VIR_FREE(processor_type);
+ return -1;
+}
+
+/* virSysinfoRead for ARMv7
+ * Gathers sysinfo data from /proc/cpuinfo */
+virSysinfoDefPtr
+virSysinfoRead(void) {
+ virSysinfoDefPtr ret = NULL;
+ char *outbuf = NULL;
+
+ if (VIR_ALLOC(ret) < 0)
+ goto no_memory;
+
+ if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to open %s"), CPUINFO);
+ return NULL;
+ }
+
+ ret->nprocessor = 0;
+ ret->processor = NULL;
+ if (virSysinfoParseProcessor(outbuf, ret) < 0)
+ goto no_memory;
+
+ if (virSysinfoParseSystem(outbuf, ret) < 0)
+ goto no_memory;
+
+ return ret;
+
+no_memory:
+ VIR_FREE(outbuf);
+ return NULL;
+}
+
+
+#elif defined(__s390__) || defined(__s390x__)
/*
we need to ignore warnings about strchr caused by -Wlogical-op
for some GCC versions.
@@ -403,6 +529,7 @@ no_memory:
!(defined(__x86_64__) || \
defined(__i386__) || \
defined(__amd64__) || \
+ defined(__arm__) || \
defined(__powerpc__))
virSysinfoDefPtr
virSysinfoRead(void) {
diff --git a/tests/sysinfodata/armcpuinfo.data b/tests/sysinfodata/armcpuinfo.data
new file mode 100644
index 0000000..6ef23ca
--- /dev/null
+++ b/tests/sysinfodata/armcpuinfo.data
@@ -0,0 +1,17 @@
+Processor : ARMv7 Processor rev 4 (v7l)
+processor : 0
+BogoMIPS : 1694.10
+
+processor : 1
+BogoMIPS : 1694.10
+
+Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt
+CPU implementer : 0x41
+CPU architecture: 7
+CPU variant : 0x0
+CPU part : 0xc0f
+CPU revision : 4
+
+Hardware : SAMSUNG EXYNOS5 (Flattened Device Tree)
+Revision : 0000
+Serial : 0000000000000000
diff --git a/tests/sysinfodata/armsysinfo.expect b/tests/sysinfodata/armsysinfo.expect
new file mode 100644
index 0000000..1af9e6d
--- /dev/null
+++ b/tests/sysinfodata/armsysinfo.expect
@@ -0,0 +1,10 @@
+<sysinfo type='smbios'>
+ <processor>
+ <entry name='socket_destination'>0</entry>
+ <entry name='type'>ARMv7 Processor rev 4 (v7l)</entry>
+ </processor>
+ <processor>
+ <entry name='socket_destination'>1</entry>
+ <entry name='type'>ARMv7 Processor rev 4 (v7l)</entry>
+ </processor>
+</sysinfo>
diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c
index 94493a3..8955208 100644
--- a/tests/sysinfotest.c
+++ b/tests/sysinfotest.c
@@ -40,7 +40,8 @@
# if defined(__s390__) || defined(__s390x__) || \
defined(__powerpc__) || defined(__powerpc64__) || \
- defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
+ defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
+ defined(__arm__)
/* from sysinfo.c */
void virSysinfoSetup(const char *decoder,
@@ -164,6 +165,18 @@ test_x86(void)
}
VIRT_TEST_MAIN(test_x86)
+# elif defined(__arm__)
+static int
+test_arm(void)
+{
+ return sysinfotest_run("arm sysinfo",
+ NULL,
+ NULL,
+ "/sysinfodata/armcpuinfo.data",
+ "/sysinfodata/armsysinfo.expect");
+}
+
+VIRT_TEST_MAIN(test_arm)
# else
int
main(void)
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH] Wire up sysinfo for LXC driver
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The sysinfo code used by QEMU is trivially portable to the
LXC driver
---
src/lxc/lxc_conf.h | 3 +++
src/lxc/lxc_driver.c | 29 +++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index b46dc32..f8f7c9a 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -35,6 +35,7 @@
# include "vircgroup.h"
# include "security/security_manager.h"
# include "configmake.h"
+# include "virsysinfo.h"
# include "virusb.h"
# define LXC_DRIVER_NAME "LXC"
@@ -55,6 +56,8 @@ struct _virLXCDriver {
virCgroupPtr cgroup;
+ virSysinfoDefPtr hostsysinfo;
+
size_t nactive;
virStateInhibitCallback inhibitCallback;
void *inhibitOpaque;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index ba14db7..17f01d5 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1457,6 +1457,8 @@ static int lxcStartup(bool privileged,
if (!lxc_driver->domainEventState)
goto cleanup;
+ lxc_driver->hostsysinfo = virSysinfoRead();
+
lxc_driver->log_libvirtd = 0; /* by default log to container logfile */
lxc_driver->have_netns = lxcCheckNetNsSupport();
@@ -1574,6 +1576,8 @@ static int lxcShutdown(void)
virLXCProcessAutoDestroyShutdown(lxc_driver);
+ virSysinfoDefFree(lxc_driver->hostsysinfo);
+
virObjectUnref(lxc_driver->activeUsbHostdevs);
virObjectUnref(lxc_driver->caps);
virObjectUnref(lxc_driver->securityManager);
@@ -4547,6 +4551,30 @@ cleanup:
}
+static char *
+lxcGetSysinfo(virConnectPtr conn, unsigned int flags)
+{
+ virLXCDriverPtr driver = conn->privateData;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ virCheckFlags(0, NULL);
+
+ if (!driver->hostsysinfo) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Host SMBIOS information is not available"));
+ return NULL;
+ }
+
+ if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
+ return NULL;
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ return NULL;
+ }
+ return virBufferContentAndReset(&buf);
+}
+
+
/* Function Tables */
static virDriver lxcDriver = {
.no = VIR_DRV_LXC,
@@ -4555,6 +4583,7 @@ static virDriver lxcDriver = {
.close = lxcClose, /* 0.4.2 */
.version = lxcVersion, /* 0.4.6 */
.getHostname = virGetHostname, /* 0.6.3 */
+ .getSysinfo = lxcGetSysinfo, /* 1.0.5 */
.nodeGetInfo = nodeGetInfo, /* 0.6.5 */
.getCapabilities = lxcGetCapabilities, /* 0.6.5 */
.listDomains = lxcListDomains, /* 0.4.2 */
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH] qemu: fix memory leak on -machine usage error
by Eric Blake
Commit f84b92ea introduced a memory leak on error; John Ferlan reported
that valgrind caught it during 'make check'.
* src/qemu/qemu_command.c (qemuBuildMachineArgStr): Plug leak.
---
Pushing under the trivial rule.
src/qemu/qemu_command.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 693d30d..29424d6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5228,6 +5228,7 @@ qemuBuildMachineArgStr(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("dump-guest-core is not available "
"with this QEMU binary"));
+ virBufferFreeAndReset(&buf);
return -1;
}
--
1.8.1.4
11 years, 7 months
[libvirt] (no subject)
by Dan Walsh
Most of them effect virt-sandbox-service, with the biggest change beeing the addition of
InteractiveContainers.
We want to be able to support OpenShift, which requres the abiltiy to run a command within a
container environement but does not want to use the systemd/unitfiles. These containers will
run a setup script and then a user process to actually run the application.
>From Dan Walsh <dwalsh(a)redhat.com> # This line is ignored.
From: Dan Walsh <dwalsh(a)redhat.com>
Subject:
In-Reply-To:
11 years, 7 months