[libvirt] [PATCH v3 00/13] parallels: implement operations with hard disks
by Dmitry Guryanov
This patch series adds ability to list existing disk images,
create a new ones and add or remove hard disk devices to the VM.
Changes in v2:
rebased to current sources
Changes in v3:
fixed errors in make syntax-check
Dmitry Guryanov (13):
parallels: add info about hard disk devices
parallels: handle disk devices in parallelsDomainDefineXML
parallels: split parallelsStorageOpen function
parallels: remove unused code from storage driver
parallels: create storage pools by VM list
parallels: fix leaks in parallelsFindVolumes
parallels: add info about volumes
parallels: fill volumes capacity parameter
parallels: split parallelsStorageVolumeDelete function
parallels: add function parallelsGetDiskBusName
parallels: add support of disks creation
parallels: apply config after VM creation
parallels: add support of removing disks
src/parallels/parallels_driver.c | 346 +++++++++++++++++++++++++--
src/parallels/parallels_storage.c | 479 +++++++++++++++++++++++++++++++------
src/parallels/parallels_utils.h | 3 +
3 files changed, 731 insertions(+), 97 deletions(-)
--
1.7.7.6
11 years, 12 months
[libvirt] [test-API][PATCH] balloon_memory: add time break before dump xml
by Wayne Sun
the xml dumped after setMemory is not accurate due to time
delay, so take 10 sec sleep before dump to show the right
xml info
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
repos/domain/balloon_memory.py | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/repos/domain/balloon_memory.py b/repos/domain/balloon_memory.py
index 7051a0a..5bf023a 100644
--- a/repos/domain/balloon_memory.py
+++ b/repos/domain/balloon_memory.py
@@ -209,6 +209,7 @@ def balloon_memory(params):
logger.debug("dump the xml description of guest virtual machine %s" %
domname)
+ time.sleep(10)
dom_xml = domobj.XMLDesc(0)
logger.debug("the xml definination is %s" % dom_xml)
@@ -240,6 +241,7 @@ def balloon_memory(params):
logger.debug("dump the xml description of \
guest virtual machine %s" % domname)
+ time.sleep(10)
dom_xml = domobj.XMLDesc(0)
logger.debug("the xml definination is %s" % dom_xml)
--
1.7.1
11 years, 12 months
[libvirt] [java PATCH] Fix build with jna >= 3.5.0
by Jiri Denemark
Since jna-3.5.0, all subclasses of com.sun.jna.Structure are required to
implement getFieldOrder method which is supposed to return a list of
fields the wrapped structure contains.
---
src/main/java/org/libvirt/jna/virConnectAuth.java | 5 +++++
src/main/java/org/libvirt/jna/virConnectCredential.java | 6 ++++++
src/main/java/org/libvirt/jna/virDomainBlockInfo.java | 4 ++++
src/main/java/org/libvirt/jna/virDomainBlockStats.java | 5 +++++
src/main/java/org/libvirt/jna/virDomainInfo.java | 5 +++++
src/main/java/org/libvirt/jna/virDomainInterfaceStats.java | 5 +++++
src/main/java/org/libvirt/jna/virDomainJobInfo.java | 7 +++++++
src/main/java/org/libvirt/jna/virDomainMemoryStats.java | 4 ++++
src/main/java/org/libvirt/jna/virError.java | 6 ++++++
src/main/java/org/libvirt/jna/virNodeInfo.java | 8 +++++++-
src/main/java/org/libvirt/jna/virSchedParameter.java | 5 +++++
src/main/java/org/libvirt/jna/virStoragePoolInfo.java | 5 +++++
src/main/java/org/libvirt/jna/virStorageVolInfo.java | 6 +++++-
src/main/java/org/libvirt/jna/virVcpuInfo.java | 4 ++++
14 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/libvirt/jna/virConnectAuth.java b/src/main/java/org/libvirt/jna/virConnectAuth.java
index 74dd65c..369d2e5 100644
--- a/src/main/java/org/libvirt/jna/virConnectAuth.java
+++ b/src/main/java/org/libvirt/jna/virConnectAuth.java
@@ -1,14 +1,19 @@
package org.libvirt.jna;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
/**
* JNA mapping for the virConnectAuth structure
*/
public class virConnectAuth extends Structure {
public Pointer credtype;
public int ncredtype;
public Libvirt.VirConnectAuthCallback cb;
public Pointer cbdata;
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "credtype", "ncredtype", "cb", "cbdata" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virConnectCredential.java b/src/main/java/org/libvirt/jna/virConnectCredential.java
index ba47482..dbfc38e 100644
--- a/src/main/java/org/libvirt/jna/virConnectCredential.java
+++ b/src/main/java/org/libvirt/jna/virConnectCredential.java
@@ -1,16 +1,22 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
/**
* JNA mapping for the virConnectCredential structure
*/
public class virConnectCredential extends Structure implements Structure.ByReference {
public int type;
public String prompt;
public String challenge;
public String defresult;
// public Pointer result;
public String result;
public int resultlen;
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "type", "prompt", "challenge", "defresult",
+ "result", "resultlen" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainBlockInfo.java b/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
index 234a381..cbd7385 100644
--- a/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
@@ -1,10 +1,14 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
public class virDomainBlockInfo extends Structure {
public long capacity;
public long allocation;
public long physical;
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "capacity", "allocation", "physical" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainBlockStats.java b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
index f29dba0..71041cc 100644
--- a/src/main/java/org/libvirt/jna/virDomainBlockStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
@@ -1,19 +1,24 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
/**
* JNA mapping for the virDomainBlockStats structure
*/
public class virDomainBlockStats extends Structure {
public long rd_req; // this is a long long in the code, so a long mapping is
// correct
public long rd_bytes;// this is a long long in the code, so a long mapping
// is correct
public long wr_req; // this is a long long in the code, so a long mapping is
// correct
public long wr_bytes;// this is a long long in the code, so a long mapping
// is correct
public long errs; // this is a long long in the code, so a long mapping is
// correct
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "rd_req", "rd_bytes", "wr_req", "wr_bytes", "errs" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainInfo.java b/src/main/java/org/libvirt/jna/virDomainInfo.java
index a93c0a5..994042a 100644
--- a/src/main/java/org/libvirt/jna/virDomainInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainInfo.java
@@ -1,15 +1,20 @@
package org.libvirt.jna;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
/**
* JNA mapping for the virDomainInfo structure
*/
public class virDomainInfo extends Structure {
public int state;
public NativeLong maxMem;
public NativeLong memory;
public short nrVirtCpu;
public long cpuTime;
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "state", "maxMem", "memory", "nrVirtCpu", "cpuTime" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
index 1cb0e66..dcdd529 100644
--- a/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
@@ -8,19 +8,24 @@ import com.sun.jna.Structure;
public class virDomainInterfaceStats extends Structure {
public long rx_bytes; // this is a long long in the code, so a long mapping
// is correct
public long rx_packets; // this is a long long in the code, so a long
// mapping is correct
public long rx_errs; // this is a long long in the code, so a long mapping
// is correct
public long rx_drop; // this is a long long in the code, so a long mapping
// is correct
public long tx_bytes; // this is a long long in the code, so a long mapping
// is correct
public long tx_packets; // this is a long long in the code, so a long
// mapping is correct
public long tx_errs; // this is a long long in the code, so a long mapping
// is correct
public long tx_drop; // this is a long long in the code, so a long mapping
// is correct
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "rx_bytes", "rx_packets", "rx_errs", "rx_drop",
+ "tx_bytes", "tx_packets", "tx_errs", "tx_drop" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainJobInfo.java b/src/main/java/org/libvirt/jna/virDomainJobInfo.java
index 98b4f59..af934ad 100644
--- a/src/main/java/org/libvirt/jna/virDomainJobInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainJobInfo.java
@@ -1,18 +1,25 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
public class virDomainJobInfo extends Structure {
public int type;
public long timeElapsed;
public long timeRemaining;
public long dataTotal;
public long dataProcessed;
public long dataRemaining;
public long memTotal;
public long memProcessed;
public long memRemaining;
public long fileTotal;
public long fileProcessed;
public long fileRemaining;
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "type", "timeElapsed", "timeRemaining", "dataTotal",
+ "dataProcessed", "dataRemaining", "memTotal", "memProcessed",
+ "memRemaining", "fileTotal", "fileProcessed", "fileRemaining" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainMemoryStats.java b/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
index 7a9f5d2..ec7b29e 100644
--- a/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
@@ -1,8 +1,12 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
public class virDomainMemoryStats extends Structure {
public int tag ;
public long val ;
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] { "tag", "val" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virError.java b/src/main/java/org/libvirt/jna/virError.java
index e2580dd..9009280 100644
--- a/src/main/java/org/libvirt/jna/virError.java
+++ b/src/main/java/org/libvirt/jna/virError.java
@@ -4,19 +4,25 @@ import com.sun.jna.Pointer;
import com.sun.jna.Structure;
/**
* JNA mapping for the virError structure
*/
public class virError extends Structure {
public int code;
public int domain;
public String message;
public int level;
public ConnectionPointer conn;
public DomainPointer dom;
public String str1;
public String str2;
public String str3;
public int int1;
public int int2;
public NetworkPointer net;
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "code", "domain", "message", "level", "conn", "dom",
+ "str1", "str2", "str3", "int1", "int2", "net" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virNodeInfo.java b/src/main/java/org/libvirt/jna/virNodeInfo.java
index 532aad9..f13eddc 100644
--- a/src/main/java/org/libvirt/jna/virNodeInfo.java
+++ b/src/main/java/org/libvirt/jna/virNodeInfo.java
@@ -6,19 +6,25 @@ import com.sun.jna.Structure;
/**
* JNA mapping for the virNodeInfo structure
*/
public class virNodeInfo extends Structure {
public class ByReference extends virNodeInfo implements Structure.ByReference {
};
public class ByValue extends virNodeInfo implements Structure.ByValue {
};
public byte model[] = new byte[32];
public NativeLong memory;
public int cpus;
public int mhz;
public int nodes;
public int sockets;
public int cores;
public int threads;
-}
\ No newline at end of file
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "model", "memory", "cpus", "mhz", "nodes",
+ "sockets", "cores", "threads" });
+ }
+}
diff --git a/src/main/java/org/libvirt/jna/virSchedParameter.java b/src/main/java/org/libvirt/jna/virSchedParameter.java
index 0013fff..9496121 100644
--- a/src/main/java/org/libvirt/jna/virSchedParameter.java
+++ b/src/main/java/org/libvirt/jna/virSchedParameter.java
@@ -1,12 +1,17 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
/**
* JNA mapping for the virSchedParameter structure
*/
public class virSchedParameter extends Structure {
public byte field[] = new byte[Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH];
public int type;
public virSchedParameterValue value;
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "field", "type", "value" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virStoragePoolInfo.java b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
index 5a98e08..7f370cd 100644
--- a/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
+++ b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
@@ -1,16 +1,21 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
/**
* JNA mapping for the virStoragePoolInfo structure
*/
public class virStoragePoolInfo extends Structure {
public int state;
public long capacity; // this is a long long in the code, so a long mapping
// is correct
public long allocation; // this is a long long in the code, so a long
// mapping is correct
public long available; // this is a long long in the code, so a long mapping
// is correct
+
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "state", "capacity", "allocation", "available" });
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virStorageVolInfo.java b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
index db8a5bd..a02219e 100644
--- a/src/main/java/org/libvirt/jna/virStorageVolInfo.java
+++ b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
@@ -1,15 +1,19 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
/**
* JNA mapping for the virStorageVolInfo structure
*/
public class virStorageVolInfo extends Structure {
public int type;
public long capacity; // this is a long long in the code, so a long mapping
// is correct
public long allocation; // this is a long long in the code, so a long
// mapping is correct
-}
\ No newline at end of file
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "type", "capacity", "allocation" });
+ }
+}
diff --git a/src/main/java/org/libvirt/jna/virVcpuInfo.java b/src/main/java/org/libvirt/jna/virVcpuInfo.java
index 16f237d..e5f4363 100644
--- a/src/main/java/org/libvirt/jna/virVcpuInfo.java
+++ b/src/main/java/org/libvirt/jna/virVcpuInfo.java
@@ -1,15 +1,19 @@
package org.libvirt.jna;
import com.sun.jna.Structure;
/**
* JNA mapping for the virVcpuInfo structure
*/
public class virVcpuInfo extends Structure {
public int number;
public int state;
public long cpuTime; // this is a long long in the code, so a long mapping
// is correct
public int cpu;
+ protected java.util.List getFieldOrder() {
+ return java.util.Arrays.asList(new String[] {
+ "number", "state", "cpuTime", "cpu" });
+ }
}
--
1.8.0
11 years, 12 months
[libvirt] [PATCH v2] bitmap: fix typo to use UL type of integer constant in virBitmapIsAllSet
by Guannan Ren
This bug leads to get incorrect vcpupin information via
qemudDomainGetVcpuPinInfo() API when the number of maximum
cpu on a host falls into a range such as 31 < ncpus < 64.
gcc warning:
left shift count >= width of type
The following bug is such the case
https://bugzilla.redhat.com/show_bug.cgi?id=876415
---
src/util/bitmap.c | 4 ++--
tests/virbitmaptest.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/util/bitmap.c b/src/util/bitmap.c
index 5ec5440..c29f5f3 100644
--- a/src/util/bitmap.c
+++ b/src/util/bitmap.c
@@ -574,8 +574,8 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap)
return false;
if (unusedBits > 0) {
- if ((bitmap->map[sz] & ((1U << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
- != ((1U << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
+ if ((bitmap->map[sz] & ((1UL << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
+ != ((1UL << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
return false;
}
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index f1eb9d5..e21bb02 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -347,6 +347,37 @@ error:
return ret;
}
+static int test7(const void *v ATTRIBUTE_UNUSED)
+{
+ virBitmapPtr bitmap;
+ size_t i;
+ size_t maxBit[] = {
+ 1, 8, 31, 32, 63, 64, 95, 96, 127, 128, 159, 160
+ };
+ size_t nmaxBit = 12;
+
+ for (i = 0; i < nmaxBit; i++) {
+ bitmap = virBitmapNew(maxBit[i]);
+ if (!bitmap)
+ goto error;
+
+ if (virBitmapIsAllSet(bitmap))
+ goto error;
+
+ virBitmapSetAll(bitmap);
+ if (!virBitmapIsAllSet(bitmap))
+ goto error;
+
+ virBitmapFree(bitmap);
+ }
+
+ return 0;
+
+error:
+ virBitmapFree(bitmap);
+ return -1;
+}
+
static int
mymain(void)
{
@@ -364,6 +395,8 @@ mymain(void)
ret = -1;
if (virtTestRun("test6", 1, test6, NULL) < 0)
ret = -1;
+ if (virtTestRun("test7", 1, test7, NULL) < 0)
+ ret = -1;
return ret;
--
1.7.1
11 years, 12 months
[libvirt] RFC: adding configuration for standard dhcp options to <network>
by Laine Stump
There have been multiple requests over the last couple years to make the
DHCP server of libvirt's virutal networks more configurable (for
example, see the following BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=824573 ).
You can see a full list of the options supported by dnsmasq with this
command:
dnsmasq --help dhcp
The biggest question here is in exactly how to represent the options in
the network XML. I can see a few different options, among them:
1) make each option its own element within <dhcp>, e.g.:
<dnsServer family='ipv4' address='x.x.x.x'/>
<dnsServer family='ipv6' address='xxxx:xxxx::1'/>
<ntpServer address='y.y.y.y'/>
<smtpServer address='z.z.z.z'/>
2) A variation of (1) where each option could appear only once, but with
two attributes, one for ipv6 address and one for ipv4:
<dnsServer address4='x.x.x.x'address6='xxxx:xxxx::1'/>
<ntpServer address4='y.y.y.y'/>
3) have a repeatable "option" element (again, a subelement of <dhcp>
that can contain any number of the options as attributes:
<option family='ipv4' dnsServer='x.x.x.x' ntpServer='y.y.y.y'
smtpServer='z.z.z.z'/>
<option family='ipv6' dnsServer='xxxx:xxxx:1'/>
(in this case, we may or may not support repeating <option> to add
more options for the same family).
4) yet another variation, where each option is a subelement of <option
family='xxxx'>:
<option family='ipv4'>
<dnsServer>x.x.x.x</dnsServer>
<ntpServer>y.y.y.y</ntpServer>
<smtpServer>z.z.z.z</smtpServer>
</option>
<option family='ipv6'>
<dnsServer>xxxx:xxxx::1</dnsServer>
</option>
I'm not sure which of these would be more straightforward for a user.
One thought I've had is that dnsmasq at least allows specifying
different groups of guest addresses (with a "tag") and applying
different options to addresses with different tags. I don't know if
we'll ever use that capability, but if we do it *seems* like any of
these methods could be adapted to specifying multiple groups.
Does anyone have a preference? (I have a narrow preference for (1),
simply because it was the first to come to my mind, but could easily be
swayed to one of the others, or something else, given a logical reason).
11 years, 12 months
[libvirt] [PATCH 0/2] Fix authentication with passwords in libssh2 connection driver
by Peter Krempa
When keyboard interactive authentication is disabled on the remote host
the usual way is to request a password and authenticate using tunneled
password authentication. Libvirt's libssh2 driver didn't have this fallback and
connections to such hosts failed.
Peter Krempa (2):
util: Add possibility to call virAuthGetPassword without conn object
libssh2_transport: Add fallback authentication method for password
auth
src/rpc/virnetsshsession.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
src/util/virauth.c | 13 ++++++----
2 files changed, 72 insertions(+), 5 deletions(-)
--
1.8.0
11 years, 12 months
[libvirt] [v0.10.2-maint][PATCH] qemu: Always format CPU topology
by Michal Privoznik
From: Jiri Denemark <jdenemar(a)redhat.com>
When libvirt cannot find a suitable CPU model for host CPU (easily
reproducible by running libvirt in a guest), it would not provide CPU
topology in capabilities XML either. Even though CPU topology is known
and can be queried by virNodeGetInfo. With this patch, CPU topology will
always be provided in capabilities XML regardless on the presence of CPU
model.
(cherry picked from commit f1c70100409562c3f402392aa667732e5f89a2c4)
Conflicts:
src/qemu/qemu_capabilities.c
src/qemu/qemu_command.c
The new code uses capabilities caching.
---
I am not sure about the correct process of this. So if there are some pointers ....
src/qemu/qemu_capabilities.c | 6 +++---
src/qemu/qemu_domain.c | 4 +++-
src/qemu/qemu_driver.c | 3 ++-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 37f1a2b..b1ef1b9 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -844,6 +844,7 @@ qemuCapsInitGuest(virCapsPtr caps,
guest->arch.defaultInfo.emulator_mtime = binary_mtime;
if (caps->host.cpu &&
+ caps->host.cpu->model &&
qemuCapsProbeCPUModels(binary, NULL, info->arch, &ncpus, NULL) == 0 &&
ncpus > 0 &&
!virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
@@ -973,12 +974,11 @@ qemuCapsInitCPU(virCapsPtr caps,
cpu->sockets = nodeinfo.sockets;
cpu->cores = nodeinfo.cores;
cpu->threads = nodeinfo.threads;
+ caps->host.cpu = cpu;
if (!(data = cpuNodeData(arch))
|| cpuDecode(cpu, data, NULL, 0, NULL) < 0)
- goto error;
-
- caps->host.cpu = cpu;
+ goto cleanup;
ret = 0;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 17ae3b9..e23ff11 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1233,7 +1233,9 @@ qemuDomainDefFormatBuf(struct qemud_driver *driver,
if ((flags & VIR_DOMAIN_XML_UPDATE_CPU) &&
def_cpu &&
(def_cpu->mode != VIR_CPU_MODE_CUSTOM || def_cpu->model)) {
- if (!driver->caps || !driver->caps->host.cpu) {
+ if (!driver->caps ||
+ !driver->caps->host.cpu ||
+ !driver->caps->host.cpu->model) {
virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("cannot get host CPU capabilities"));
goto cleanup;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0258dbb..c1c8fa4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10083,7 +10083,8 @@ qemuCPUCompare(virConnectPtr conn,
if (!driver->caps) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot get host capabilities"));
- } else if (!driver->caps->host.cpu) {
+ } else if (!driver->caps->host.cpu ||
+ !driver->caps->host.cpu->model) {
VIR_WARN("cannot get host CPU capabilities");
ret = VIR_CPU_COMPARE_INCOMPATIBLE;
} else {
--
1.7.8.6
11 years, 12 months
[libvirt] [PATCH 1/2] node_memory: Do not fail if there is parameter unsupported
by Osier Yang
It makes no sense to fail the whole command if there is parameter
unsupported by the kernel. This patch fixes it by ignoring the
unsupported parameter for getMemoryParameters, and ignoring the
unsupported parameter for setMemoryParameters too if there are
more than one parameters to set, otherwise error out.
---
src/libvirt.c | 12 +++--
src/nodeinfo.c | 119 ++++++++++++++++++++++++++++++++++----------------------
2 files changed, 79 insertions(+), 52 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 4af6089..93ec068 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -6746,10 +6746,10 @@ error:
* @nparams: pointer to number of memory parameters; input and output
* @flags: extra flags; not used yet, so callers should always pass 0
*
- * Get all node memory parameters. On input, @nparams gives the size
- * of the @params array; on output, @nparams gives how many slots were
- * filled with parameter information, which might be less but will
- * not exceed the input value.
+ * Get all node memory parameters (parameter unsupported by OS will be
+ * ignored). On input, @nparams gives the size of the @params array;
+ * on output, @nparams gives how many slots were filled with parameter
+ * information, which might be less but will not exceed the input value.
*
* As a special case, calling with @params as NULL and @nparams as 0 on
* input will cause @nparams on output to contain the number of parameters
@@ -6811,7 +6811,9 @@ error:
* value nparams of virDomainGetSchedulerType)
* @flags: extra flags; not used yet, so callers should always pass 0
*
- * Change all or a subset of the node memory tunables.
+ * Change all or a subset of the node memory tunables. Tunable
+ * unsupported by OS wll be ignored if @nparams is not 1, otherwise
+ * the function fails.
*
* Note that it's not recommended to use this function while the
* outside tuning program is running (such as ksmtuned under Linux),
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 75d6524..718a3a4 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -1058,21 +1058,13 @@ nodeGetCPUBitmap(int *max_id ATTRIBUTE_UNUSED)
#ifdef __linux__
static int
-nodeSetMemoryParameterValue(const char *field,
+nodeSetMemoryParameterValue(const char *path,
virTypedParameterPtr param)
{
- char *path = NULL;
char *strval = NULL;
int ret = -1;
int rc = -1;
- if (virAsprintf(&path, "%s/%s",
- SYSFS_MEMORY_SHARED_PATH, field) < 0) {
- virReportOOMError();
- ret = -2;
- goto cleanup;
- }
-
if (virAsprintf(&strval, "%u", param->value.ui) == -1) {
virReportOOMError();
ret = -2;
@@ -1080,13 +1072,12 @@ nodeSetMemoryParameterValue(const char *field,
}
if ((rc = virFileWriteStr(path, strval, 0)) < 0) {
- virReportSystemError(-rc, _("failed to set %s"), field);
+ virReportSystemError(-rc, _("failed to set %s"), param->field);
goto cleanup;
}
ret = 0;
cleanup:
- VIR_FREE(path);
VIR_FREE(strval);
return ret;
}
@@ -1101,7 +1092,9 @@ nodeSetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
virCheckFlags(0, -1);
#ifdef __linux__
- int ret = 0;
+ char *path = NULL;
+ int ret = -1;
+ int rc;
int i;
if (virTypedParameterArrayValidate(params, nparams,
@@ -1117,30 +1110,40 @@ nodeSetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
- if (STREQ(param->field,
- VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN)) {
- ret = nodeSetMemoryParameterValue("pages_to_scan", param);
+ char *field = strchr(param->field, '_');
+ field++;
+ if (virAsprintf(&path, "%s/%s",
+ SYSFS_MEMORY_SHARED_PATH, field) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
- /* Out of memory */
- if (ret == -2)
- return -1;
- } else if (STREQ(param->field,
- VIR_NODE_MEMORY_SHARED_SLEEP_MILLISECS)) {
- ret = nodeSetMemoryParameterValue("sleep_millisecs", param);
+ /* Ignore the unsupported the param field if there is other
+ * parameter to set, otherwise error out.
+ */
+ if (!virFileExists(path)) {
+ if (nparams == 1) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("Parameter '%s' is not supported by "
+ "this kernel"), param->field);
+ goto cleanup;
+ } else {
+ VIR_WARN("Parameter '%s' is not supported by this kernel",
+ param->field);
+ continue;
+ }
+ }
- /* Out of memory */
- if (ret == -2)
- return -1;
- } else if (STREQ(param->field,
- VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES)) {
- ret = nodeSetMemoryParameterValue("merge_across_nodes", param);
+ rc = nodeSetMemoryParameterValue(path, param);
- /* Out of memory */
- if (ret == -2)
- return -1;
- }
+ /* Out of memory */
+ if (rc == -2)
+ goto cleanup;
}
+ ret = 0;
+cleanup:
+ VIR_FREE(path);
return ret;
#else
virReportError(VIR_ERR_NO_SUPPORT, "%s",
@@ -1167,6 +1170,11 @@ nodeGetMemoryParameterValue(const char *field,
goto cleanup;
}
+ if (!virFileExists(path)) {
+ ret = -2;
+ goto cleanup;
+ }
+
if (virFileReadAll(path, 1024, &buf) < 0)
goto cleanup;
@@ -1217,6 +1225,7 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned long long pages_volatile;
unsigned long long full_scans = 0;
int i;
+ int ret;
if ((*nparams) == 0) {
*nparams = NODE_MEMORY_PARAMETERS_NUM;
@@ -1228,8 +1237,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
switch (i) {
case 0:
- if (nodeGetMemoryParameterValue("pages_to_scan",
- &pages_to_scan) < 0)
+ ret = nodeGetMemoryParameterValue("pages_to_scan", &pages_to_scan);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN,
@@ -1239,8 +1250,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case 1:
- if (nodeGetMemoryParameterValue("sleep_millisecs",
- &sleep_millisecs) < 0)
+ ret = nodeGetMemoryParameterValue("sleep_millisecs", &sleep_millisecs);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_SLEEP_MILLISECS,
@@ -1250,8 +1263,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case 2:
- if (nodeGetMemoryParameterValue("pages_shared",
- &pages_shared) < 0)
+ ret = nodeGetMemoryParameterValue("pages_shared", &pages_shared);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_PAGES_SHARED,
@@ -1261,8 +1276,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case 3:
- if (nodeGetMemoryParameterValue("pages_sharing",
- &pages_sharing) < 0)
+ ret = nodeGetMemoryParameterValue("pages_sharing", &pages_sharing);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_PAGES_SHARING,
@@ -1272,8 +1289,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case 4:
- if (nodeGetMemoryParameterValue("pages_unshared",
- &pages_unshared) < 0)
+ ret = nodeGetMemoryParameterValue("pages_unshared", &pages_unshared);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_PAGES_UNSHARED,
@@ -1283,8 +1302,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case 5:
- if (nodeGetMemoryParameterValue("pages_volatile",
- &pages_volatile) < 0)
+ ret = nodeGetMemoryParameterValue("pages_volatile", &pages_volatile);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_PAGES_VOLATILE,
@@ -1294,8 +1315,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case 6:
- if (nodeGetMemoryParameterValue("full_scans",
- &full_scans) < 0)
+ ret = nodeGetMemoryParameterValue("full_scans", &full_scans);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_FULL_SCANS,
@@ -1305,8 +1328,10 @@ nodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case 7:
- if (nodeGetMemoryParameterValue("merge_across_nodes",
- &merge_across_nodes) < 0)
+ ret = nodeGetMemoryParameterValue("merge_across_nodes", &merge_across_nodes);
+ if (ret == -2)
+ continue;
+ else if (ret == -1)
return -1;
if (virTypedParameterAssign(param, VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES,
--
1.7.7.6
11 years, 12 months
[libvirt] [PATCH] storage: fix device detach regression with cgroup ACLs
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=876828
Commit 38c4a9cc introduced a regression in hot unplugging of disks
from qemu, where cgroup device ACLs were no longer being revoked
(thankfully not a security hole: cgroup ACLs only prevent open()
of the disk; so reverting the ACL prevents future abuse but doesn't
stop abuse from an fd that was already opened before the ACL change).
The actual regression is due to a latent bug. The hot unplug code
was computing the set of files to do cgroup ACL revocation based
on the XML passed in by the user, rather than based on the domain's
details on which disk was being deleted. As long as the revoke
path was always recomputing the backing chain, this didn't really
matter; but now that we want to compute the chain exactly once and
remember that computation, we need to hang on to the backing chain
until after the revoke has happened.
* src/qemu/qemu_hotplug.c (qemuDomainDetachPciDiskDevice):
Transfer backing chain before deletion.
---
The patch is deceptively small for how long it took me to figure out
why we had a regression :)
src/qemu/qemu_hotplug.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index ae8381e..0bc2259 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1999,6 +1999,8 @@ int qemuDomainDetachPciDiskDevice(struct qemud_driver *driver,
virDomainDiskRemove(vm->def, i);
+ dev->data.disk->backingChain = detach->backingChain;
+ detach->backingChain = NULL;
virDomainDiskDefFree(detach);
if (virSecurityManagerRestoreImageLabel(driver->securityManager,
--
1.7.1
11 years, 12 months
[libvirt] [PATCH] S390: Assign default model "virtio" for network interfaces
by Viktor Mihajlovski
If a network interface model is not specified, libvirt will run
into an unchecked NULL pointer coredump. On the other hand if
the empty model is ignored, a PCI bus address would be generated,
which is not supported by S390.
Since the only valid network type model for S390 is virtio,
we use this as the default value, which is the same for QEMU.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/qemu/qemu_command.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7736575..592ab24 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -810,9 +810,14 @@ qemuDomainPrimeS390VirtioDevices(virDomainDefPtr def,
}
for (i = 0; i < def->nnets ; i++) {
+ if (STRPREFIX(def->os.arch, "s390") &&
+ def->nets[i]->model == NULL) {
+ def->nets[i]->model = strdup("virtio");
+ }
if (STREQ(def->nets[i]->model,"virtio") &&
- def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+ def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
def->nets[i]->info.type = type;
+ }
}
for (i = 0; i < def->ncontrollers ; i++) {
--
1.7.0.4
11 years, 12 months