[libvirt] ESXi 4.1 Driver
by Sherif Nagy
Dear All,
Any idea what release of Libvirt has or will have the support for ESXi 4.1
driver?
Thank You,
Regards,
Sherif
14 years
Re: [libvirt] SPAM-LOW: Domain.GetInfo error
by arnaud.champion@devatom.fr
?Hi,
In fact, when you compile libvirt with mingwin/msys, the binaries are compiled in 32 bits, even it runs on a 64 bits system. Accordingly, C# bindings must be targeted as x86 (32 bits) when compiling them. This isn't a problem for a 64 bits application which use bindings, .Net make the trick to make it works.
I haven't made any test with xen (I haven't xen) but if your sample works, it means libvirt is compiled with xen support.
Happy halloween to you also.
Arnaud
From: 黄亮
Sent: Sunday, October 31, 2010 6:52 AM
To: arnaud.champion(a)devatom.fr
Subject: Re: Re: SPAM-LOW: Domain.GetInfo error
Hi,
Thanks for your reply.
It works with the patch you provide in last letter.
But I don't understand "x86 target" you mentioned, does it mean if I want to make the code run, the server which runs xend & libvirtd must be a x86 arch, not a x64 arch?
As to the question "are you sure also that libvirt dll is compiled with xen support ?"
I just follow the instructions on http://github.com/photron/msys_setup, without the ESX support, I think it should support Xen, though it isn't write in explicit.
Anyway, at least it's working. Thanks for your reply.
Regards and Best wishes, and Happy Halloween XD
2010-10-31
--------------------------------------------------------------------------------
Lancer
--------------------------------------------------------------------------------
发件人: arnaud.champion(a)devatom.fr
发送时间: 2010-10-31 01:21:52
收件人: 黄亮
抄送: libvir-list(a)redhat.com
主题: Re: SPAM-LOW: Domain.GetInfo error
Hi,
So, at first, are you sure that conn != IntPtr.Zero and pDomain != IntPtr.Zero.
if both pointer are ok, can you please check the DomainInfo marshal, I have just sended patch today around this structure, and I think the patch is not yet pushed to the git.
The DomainInfo structure must be marshaled in this way :
/// <summary>
/// Structure to handle domain informations
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class DomainInfo
{
/// <summary>
/// The running state, one of virDomainState.
/// </summary>
private byte state;
/// <summary>
/// The maximum memory in KBytes allowed.
/// </summary>
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr maxMem;
/// <summary>
/// The memory in KBytes used by the domain.
/// </summary>
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr memory;
/// <summary>
/// The number of virtual CPUs for the domain.
/// </summary>
public ushort nrVirtCpu;
/// <summary>
/// The CPU time used in nanoseconds.
/// </summary>
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr cpuTime;
/// <summary>
/// The running state, one of virDomainState.
/// </summary>
public DomainState State { get { return (DomainState)state; } }
}
Also, another important thing change : the libvirt bindings project must have an x86 target to make this marshaling working. This is also in the patch.
Another thing, you can also use Errors.GetLastErro() method to identify the problem, it return an error class which can inform you about the problem.
Best regards,
Arnaud
PS : are you sure also that libvirt dll is compiled with xen support ?
From: 黄亮
Sent: Saturday, October 30, 2010 7:07 PM
To: arnaud.champion
Subject: SPAM-LOW: Domain.GetInfo error
Dear Arnaud
Here is my test code. Function Domain.GetInfo return -1 and I don't know where is the mistake.
Would you do me a favor to point out the problem? Thank you!
Code:
IntPtr conn = Connect.Open("xen+tcp://192.168.0.1?no_verify=1");
String DomainName = e.Node.Text;
IntPtr pDomain = Domain.LookupByName(conn, DomainName);
DomainInfo aInfo = new DomainInfo();
if (Domain.GetInfo(pDomain, aInfo) == -1)
{
MessageBox.Show("Get Info error");
return;
}
2010-10-31
--------------------------------------------------------------------------------
黄亮
__________ Information from ESET Smart Security, version of virus signature database 5576 (20101029) __________
The message was checked by ESET Smart Security.
http://www.eset.com
14 years
Re: [libvirt] SPAM-LOW: Domain.GetInfo error
by arnaud.champion@devatom.fr
?Hi,
So, at first, are you sure that conn != IntPtr.Zero and pDomain != IntPtr.Zero.
if both pointer are ok, can you please check the DomainInfo marshal, I have just sended patch today around this structure, and I think the patch is not yet pushed to the git.
The DomainInfo structure must be marshaled in this way :
/// <summary>
/// Structure to handle domain informations
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class DomainInfo
{
/// <summary>
/// The running state, one of virDomainState.
/// </summary>
private byte state;
/// <summary>
/// The maximum memory in KBytes allowed.
/// </summary>
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr maxMem;
/// <summary>
/// The memory in KBytes used by the domain.
/// </summary>
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr memory;
/// <summary>
/// The number of virtual CPUs for the domain.
/// </summary>
public ushort nrVirtCpu;
/// <summary>
/// The CPU time used in nanoseconds.
/// </summary>
[MarshalAs(UnmanagedType.SysUInt)]
public UIntPtr cpuTime;
/// <summary>
/// The running state, one of virDomainState.
/// </summary>
public DomainState State { get { return (DomainState)state; } }
}
Also, another important thing change : the libvirt bindings project must have an x86 target to make this marshaling working. This is also in the patch.
Another thing, you can also use Errors.GetLastErro() method to identify the problem, it return an error class which can inform you about the problem.
Best regards,
Arnaud
PS : are you sure also that libvirt dll is compiled with xen support ?
From: 黄亮
Sent: Saturday, October 30, 2010 7:07 PM
To: arnaud.champion
Subject: SPAM-LOW: Domain.GetInfo error
Dear Arnaud
Here is my test code. Function Domain.GetInfo return -1 and I don't know where is the mistake.
Would you do me a favor to point out the problem? Thank you!
Code:
IntPtr conn = Connect.Open("xen+tcp://192.168.0.1?no_verify=1");
String DomainName = e.Node.Text;
IntPtr pDomain = Domain.LookupByName(conn, DomainName);
DomainInfo aInfo = new DomainInfo();
if (Domain.GetInfo(pDomain, aInfo) == -1)
{
MessageBox.Show("Get Info error");
return;
}
2010-10-31
--------------------------------------------------------------------------------
黄亮
14 years
[libvirt] virDomainInfo marshalling prolem
by arnaud.champion@devatom.fr
?Hi,
I am working on the marshaling of the virDomainInfo structure. I have marshalled it in this way :
/// <summary>
/// Structure to handle domain informations
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class DomainInfo
{
/// <summary>
/// The running state, one of virDomainState.
/// </summary>
private Byte state;
/// <summary>
/// The maximum memory in KBytes allowed.
/// </summary>
public int maxMem;
/// <summary>
/// The memory in KBytes used by the domain.
/// </summary>
public int memory;
/// <summary>
/// The number of virtual CPUs for the domain.
/// </summary>
public short nrVirtCpu;
/// <summary>
/// The CPU time used in nanoseconds.
/// </summary>
public long cpuTime;
/// <summary>
/// The running state, one of virDomainState.
/// </summary>
public DomainState State { get { return (DomainState)state; } }
}
It work fine in 32 bits, but not in 64 bits, it seems that packing in 64 bits is different so infos are not in order. Am I right ?
Regards,
Arnaud
14 years
[libvirt] [PATCH C#] Always close connections and free domains
by Matthias Bolte
Also free the unmanaged authDataPtr in the virConnectOpenAuth
examples.
---
examples/MonoDevelop/virConnectOpen/MainWindow.cs | 10 ++++++++++
.../MonoDevelop/virConnectOpenAuth/MainWindow.cs | 20 +++++++++++++-------
examples/VisualStudio/virConnectOpen/Form1.cs | 10 ++++++++++
examples/VisualStudio/virConnectOpenAuth/Form1.cs | 16 +++++++++++-----
4 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/examples/MonoDevelop/virConnectOpen/MainWindow.cs b/examples/MonoDevelop/virConnectOpen/MainWindow.cs
index 849f99f..0abae49 100644
--- a/examples/MonoDevelop/virConnectOpen/MainWindow.cs
+++ b/examples/MonoDevelop/virConnectOpen/MainWindow.cs
@@ -25,19 +25,29 @@ public partial class MainWindow : Gtk.Window
protected virtual void OnButton1Clicked (object sender, System.EventArgs e)
{
+ StoragePoolListStore.Clear ();
+
IntPtr conn = Connect.Open(entry1.Text);
if (conn != IntPtr.Zero)
{
int numOfStoragePools = Connect.NumOfStoragePools(conn);
if (numOfStoragePools == -1)
+ {
ShowError("Unable to get the number of storage pools");
+ goto cleanup;
+ }
string[] storagePoolsNames = new string[numOfStoragePools];
int listStoragePools = Connect.ListStoragePools(conn, ref storagePoolsNames, numOfStoragePools);
if (listStoragePools == -1)
+ {
ShowError("Unable to list storage pools");
+ goto cleanup;
+ }
foreach (string storagePoolName in storagePoolsNames)
AddStoragePoolInTreeView(storagePoolName);
+ cleanup:
+ Connect.Close(conn);
}
else
{
diff --git a/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs b/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs
index 996a417..d02acd4 100644
--- a/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs
+++ b/examples/MonoDevelop/virConnectOpenAuth/MainWindow.cs
@@ -43,8 +43,12 @@ public partial class MainWindow : Gtk.Window
Application.Quit ();
a.RetVal = true;
}
+
protected virtual void OnButton1Clicked (object sender, System.EventArgs e)
{
+ // Remove all items
+ domainListStore.Clear ();
+
// Fill a structure to pass username and password to callbacks
AuthData authData = new AuthData { password = entry3.Text, user_name = entry2.Text };
IntPtr authDataPtr = Marshal.AllocHGlobal(Marshal.SizeOf(authData));
@@ -64,7 +68,8 @@ public partial class MainWindow : Gtk.Window
// Request the connection
IntPtr conn = Connect.OpenAuth(entry1.Text, ref auth, 0);
-
+ Marshal.FreeHGlobal(authDataPtr);
+
if (conn != IntPtr.Zero)
{
// Get the number of defined (not running) domains
@@ -73,7 +78,7 @@ public partial class MainWindow : Gtk.Window
if (Connect.ListDefinedDomains(conn, ref definedDomainNames, numOfDefinedDomains) == -1)
{
ShowError("Unable to list defined domains");
- return;
+ goto cleanup;
}
// Add the domain names to the listbox
@@ -88,7 +93,7 @@ public partial class MainWindow : Gtk.Window
if (Connect.ListDomains(conn, runningDomainIDs, numOfRunningDomain) == -1)
{
ShowError("Unable to list running domains");
- return;
+ goto cleanup;
}
// Add the domain names to the listbox
@@ -98,16 +103,19 @@ public partial class MainWindow : Gtk.Window
if (domainPtr == IntPtr.Zero)
{
ShowError("Unable to lookup domains by id");
- return;
+ goto cleanup;
}
string domainName = Domain.GetName(domainPtr);
+ Domain.Free(domainPtr);
if (string.IsNullOrEmpty(domainName))
{
ShowError("Unable to get domain name");
- return;
+ goto cleanup;
}
AddDomainInTreeView(domainName);
}
+
+ cleanup:
Connect.Close(conn);
}
else
@@ -156,7 +164,5 @@ public partial class MainWindow : Gtk.Window
}
return 0;
}
-
-
}
diff --git a/examples/VisualStudio/virConnectOpen/Form1.cs b/examples/VisualStudio/virConnectOpen/Form1.cs
index 870b83d..240aaaa 100644
--- a/examples/VisualStudio/virConnectOpen/Form1.cs
+++ b/examples/VisualStudio/virConnectOpen/Form1.cs
@@ -27,18 +27,28 @@ namespace virConnectOpen
private void btnConnect_Click(object sender, EventArgs e)
{
+ lbStoragePool.Items.Clear();
+
IntPtr conn = Connect.Open(tbURI.Text);
if (conn != IntPtr.Zero)
{
int numOfStoragePools = Connect.NumOfStoragePools(conn);
if (numOfStoragePools == -1)
+ {
ShowError("Unable to get the number of storage pools");
+ goto cleanup;
+ }
string[] storagePoolsNames = new string[numOfStoragePools];
int listStoragePools = Connect.ListStoragePools(conn, ref storagePoolsNames, numOfStoragePools);
if (listStoragePools == -1)
+ {
ShowError("Unable to list storage pools");
+ goto cleanup;
+ }
foreach (string storagePoolName in storagePoolsNames)
lbStoragePool.Items.Add(storagePoolName);
+ cleanup:
+ Connect.Close(conn);
}
else
{
diff --git a/examples/VisualStudio/virConnectOpenAuth/Form1.cs b/examples/VisualStudio/virConnectOpenAuth/Form1.cs
index 7901c27..87634a0 100644
--- a/examples/VisualStudio/virConnectOpenAuth/Form1.cs
+++ b/examples/VisualStudio/virConnectOpenAuth/Form1.cs
@@ -44,6 +44,8 @@ namespace virConnectOpenAuth
private void btnConnect_Click(object sender, EventArgs e)
{
+ lbDomains.Items.Clear();
+
// Fill a structure to pass username and password to callbacks
AuthData authData = new AuthData { password = tbPassword.Text, user_name = tbUsername.Text };
IntPtr authDataPtr = Marshal.AllocHGlobal(Marshal.SizeOf(authData));
@@ -62,6 +64,7 @@ namespace virConnectOpenAuth
// Request the connection
IntPtr conn = Connect.OpenAuth(tbURI.Text, ref auth, 0);
+ Marshal.FreeHGlobal(authDataPtr);
if (conn != IntPtr.Zero)
{
@@ -70,9 +73,9 @@ namespace virConnectOpenAuth
string[] definedDomainNames = new string[numOfDefinedDomains];
if (Connect.ListDefinedDomains(conn, ref definedDomainNames, numOfDefinedDomains) == -1)
{
- MessageBox.Show("Unable to list defined domains", "List defined domains failed", MessageBoxButtons.OK,
+ MessageBox.Show("Unable to list defined domains", "List defined domains failed", MessageBoxButtons.OK,
MessageBoxIcon.Error);
- return;
+ goto cleanup;
}
// Add the domain names to the listbox
@@ -86,7 +89,7 @@ namespace virConnectOpenAuth
{
MessageBox.Show("Unable to list running domains", "List running domains failed", MessageBoxButtons.OK,
MessageBoxIcon.Error);
- return;
+ goto cleanup;
}
// Add the domain names to the listbox
@@ -97,17 +100,20 @@ namespace virConnectOpenAuth
{
MessageBox.Show("Unable to lookup domains by id", "Lookup domain failed", MessageBoxButtons.OK,
MessageBoxIcon.Error);
- return;
+ goto cleanup;
}
string domainName = Domain.GetName(domainPtr);
+ Domain.Free(domainPtr);
if (string.IsNullOrEmpty(domainName))
{
MessageBox.Show("Unable to get domain name", "Get domain name failed", MessageBoxButtons.OK,
MessageBoxIcon.Error);
- return;
+ goto cleanup;
}
lbDomains.Items.Add(domainName);
}
+
+ cleanup:
Connect.Close(conn);
}
else
--
1.7.0.4
14 years
[libvirt] Lxc support
by Jean-Philippe Menil
Hi,
i'm trying to test the lxc support in libvirt, but but libvirt failed to
start container with error "lxcContainerAvailable:897 : clone call
returned Operation not permitted, container support is not enabled"
Althought i've compiled libvirt with th lxc support:
configure: Configuration summary
configure: =====================
configure:
configure: Drivers
configure:
configure: Xen: no
configure: Proxy: no
configure: QEMU: yes
configure: UML: yes
configure: OpenVZ: no
configure: VBox: no
configure: XenAPI: no
configure: LXC: yes
configure: PHYP: no
configure: ONE: no
configure: ESX: no
configure: Test: yes
configure: Remote: yes
configure: Network: yes
configure: Libvirtd: yes
configure: netcf: no
configure: macvtap: yes
configure: virtport: no
Here is my xml:
<domain type='lxc'>
<name>lxc1</name>
<memory>500000</memory>
<os>
<type>exe</type>
<init>/bin/sh</init>
</os>
<vcpu>1</vcpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/lib/libvirt/libvirt_lxc</emulator>
<filesystem type='mount'>
<source dir='/var/lib/lxc/lxc1/rootfs'/>
<target dir='/'/>
</filesystem>
<interface type='bridge'>
<source bridge='U13'/>
<target dev='veth0'/>
</interface>
<console type='pty' >
<target port='5'/>
</console>
</devices>
</domain>
And here are the errors:
10:41:09.968: debug : virCgroupNew:542 : New group /
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping 0:cpu
at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
1:cpuacct at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
2:cpuset at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
3:memory at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
4:devices at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
5:freezer at /var/local/cgroup in
10:41:09.968: debug : virCgroupNew:542 : New group /libvirt
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping 0:cpu
at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
1:cpuacct at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
2:cpuset at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
3:memory at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
4:devices at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
5:freezer at /var/local/cgroup in
10:41:09.968: debug : virCgroupMakeGroup:484 : Make group /libvirt
10:41:09.968: debug : virCgroupMakeGroup:496 : Make controller
/var/local/cgroup/libvirt/
10:41:09.968: debug : virCgroupMakeGroup:496 : Make controller
/var/local/cgroup/libvirt/
10:41:09.968: debug : virCgroupMakeGroup:496 : Make controller
/var/local/cgroup/libvirt/
10:41:09.968: debug : virCgroupMakeGroup:496 : Make controller
/var/local/cgroup/libvirt/
10:41:09.968: debug : virCgroupMakeGroup:496 : Make controller
/var/local/cgroup/libvirt/
10:41:09.968: debug : virCgroupMakeGroup:496 : Make controller
/var/local/cgroup/libvirt/
10:41:09.968: debug : virCgroupNew:542 : New group /libvirt/lxc
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping 0:cpu
at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
1:cpuacct at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
2:cpuset at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
3:memory at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
4:devices at /var/local/cgroup in
10:41:09.968: debug : virCgroupDetect:232 : Detected mount/mapping
5:freezer at /var/local/cgroup in
10:41:09.968: debug : virCgroupMakeGroup:484 : Make group /libvirt/lxc
10:41:09.968: debug : virCgroupMakeGroup:496 : Make controller
/var/local/cgroup/libvirt/lxc/
10:41:09.968: debug : lxcControllerRun:595 : Setting up private /dev/pts
10:41:10.012: debug : lxcControllerRun:621 : Mouting 'devpts' on
/var/lib/lxc/lxc1/rootfs/dev/pts
10:41:10.012: debug : lxcControllerRun:636 : Opening tty on private
/var/lib/lxc/lxc1/rootfs/dev/pts/ptmx
10:41:10.044: debug : lxcContainerAvailable:897 : clone call returned
Operation not permitted, container support is not enabled
10:41:10.044: debug : lxcContainerStart:848 : Enable network namespaces
10:41:10.076: debug : lxcContainerStart:854 : clone() completed, new
container PID is -1
10:41:10.076: error : lxcContainerStart:858 : Failed to run clone
container: Operation not permitted
10:41:10.076: debug : vethDelete:159 : veth: veth1
10:41:10.076: debug : virRunWithHook:818 : ip link del veth1
Can someone tell me what i'm doing wrong?
Many thanks.
Regards.
14 years
[libvirt] [PATCH] build: cleanup declaration of xen tests.
by Diego Elio Pettenò
Only build statstest and reconnect if they should be used, so add them
behind the ENABLE_XEN_TESTS conditional.
---
tests/Makefile.am | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9720b6e..20b6805 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,11 +73,14 @@ EXTRA_DIST = \
qemuhelpdata
check_PROGRAMS = virshtest conftest sockettest \
- nodeinfotest statstest qparamtest virbuftest
+ nodeinfotest qparamtest virbuftest
if WITH_XEN
check_PROGRAMS += xml2sexprtest sexpr2xmltest \
- reconnect xmconfigtest xencapstest
+ xmconfigtest xencapstest
+if ENABLE_XEN_TESTS
+check_PROGRAMS += statstest reconnect
+endif
endif
if WITH_QEMU
check_PROGRAMS += qemuxml2argvtest qemuxml2xmltest qemuargv2xmltest qemuhelptest
@@ -149,7 +152,6 @@ EXTRA_DIST += $(test_scripts)
TESTS = virshtest \
nodeinfotest \
- statstest \
qparamtest \
virbuftest \
sockettest \
@@ -161,7 +163,7 @@ TESTS += xml2sexprtest \
xmconfigtest \
xencapstest
if ENABLE_XEN_TESTS
-TESTS += reconnect
+TESTS += reconnect statstest
endif
endif
--
1.7.3.2
14 years
[libvirt] [PATCH 1/2] support compression at virsh dump
by KAMEZAWA Hiroyuki
>From 4f74c4a69785432258ad5ea5e695d1b94aaa5b30 Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
Date: Thu, 28 Oct 2010 16:31:46 +0900
Subject: [PATCH 1/2] add compression support for "virsh dump"
Add dump_image_format[] to qemu.conf and support compressed dump
at virsh dump. coredump compression is important for saving disk space
in an environment where multiple guests run.
In general, "disk space for dump" is specially allocated and will be
a dead space in the system. It's used only at emergency. So, it's better
to have both of save_image_format and dump_image_format. "save" is done
in scheduled manner with enough calculated disk space for it.
This code reuses some of save_image_format[] and supports the same format.
Changelog:
- modified libvirtd_qemu.aug
- modified test_libvirtd_qemu.aug
- fixed error handling of qemudSaveCompressionTypeFromString()
---
src/qemu/libvirtd_qemu.aug | 1 +
src/qemu/qemu.conf | 4 +++
src/qemu/qemu_conf.c | 11 ++++++++++
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 41 ++++++++++++++++++++++++++++++++------
src/qemu/test_libvirtd_qemu.aug | 2 +
6 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index b9ace3e..66994fd 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -36,6 +36,7 @@ module Libvirtd_qemu =
| str_array_entry "cgroup_controllers"
| str_array_entry "cgroup_device_acl"
| str_entry "save_image_format"
+ | str_entry "dump_image_format"
| str_entry "hugetlbfs_mount"
| bool_entry "relaxed_acs_check"
| bool_entry "vnc_allow_host_audio"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 53b76e7..e2c581e 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -145,7 +145,11 @@
# saving a domain in order to save disk space; the list above is in descending
# order by performance and ascending order by compression ratio.
#
+# save_image_format is used when you use 'virsh save' at scheduled saving.
+# dump_image_format is used when you use 'virsh dump' at emergency crashdump.
+#
# save_image_format = "raw"
+# dump_image_format = "raw"
# If provided by the host and a hugetlbfs mount point is configured,
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 5bd3d4c..b5c17b5 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -325,6 +325,17 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
}
}
+ p = virConfGetValue (conf, "dump_image_format");
+ CHECK_TYPE ("dump_image_format", VIR_CONF_STRING);
+ if (p && p->str) {
+ VIR_FREE(driver->dumpImageFormat);
+ if (!(driver->dumpImageFormat = strdup(p->str))) {
+ virReportOOMError();
+ virConfFree(conf);
+ return -1;
+ }
+ }
+
p = virConfGetValue (conf, "hugetlbfs_mount");
CHECK_TYPE ("hugetlbfs_mount", VIR_CONF_STRING);
if (p && p->str) {
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 530dcdb..bbe6887 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -164,6 +164,7 @@ struct qemud_driver {
virSecurityDriverPtr securitySecondaryDriver;
char *saveImageFormat;
+ char *dumpImageFormat;
pciDeviceList *activePciHostdevs;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b119ca1..51ad50b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5907,11 +5907,22 @@ static int qemudDomainCoreDump(virDomainPtr dom,
int resume = 0, paused = 0;
int ret = -1, fd = -1;
virDomainEventPtr event = NULL;
- const char *args[] = {
- "cat",
- NULL,
- };
+ int compress;
qemuDomainObjPrivatePtr priv;
+ /*
+ * We reuse "save" flag for "dump" here. Then, we can support the same
+ * format in "save" and "dump".
+ */
+ compress = QEMUD_SAVE_FORMAT_RAW;
+ if (driver->dumpImageFormat) {
+ compress = qemudSaveCompressionTypeFromString(driver->dumpImageFormat);
+ if (compress < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Invalid dump image format specified in "
+ "configuration file"));
+ return -1;
+ }
+ }
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -5978,9 +5989,25 @@ static int qemudDomainCoreDump(virDomainPtr dom,
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- ret = qemuMonitorMigrateToFile(priv->mon,
- QEMU_MONITOR_MIGRATE_BACKGROUND,
- args, path, 0);
+ if (compress == QEMUD_SAVE_FORMAT_RAW) {
+ const char *args[] = {
+ "cat",
+ NULL,
+ };
+ ret = qemuMonitorMigrateToFile(priv->mon,
+ QEMU_MONITOR_MIGRATE_BACKGROUND,
+ args, path, 0);
+ } else {
+ const char *prog = qemudSaveCompressionTypeToString(compress);
+ const char *args[] = {
+ prog,
+ "-c",
+ NULL,
+ };
+ ret = qemuMonitorMigrateToFile(priv->mon,
+ QEMU_MONITOR_MIGRATE_BACKGROUND,
+ args, path, 0);
+ }
qemuDomainObjExitMonitorWithDriver(driver, vm);
if (ret < 0)
goto endjob;
diff --git a/src/qemu/test_libvirtd_qemu.aug b/src/qemu/test_libvirtd_qemu.aug
index 6788346..efbf642 100644
--- a/src/qemu/test_libvirtd_qemu.aug
+++ b/src/qemu/test_libvirtd_qemu.aug
@@ -94,6 +94,8 @@ cgroup_device_acl = [ \"/dev/null\", \"/dev/full\", \"/dev/zero\" ]
save_image_format = \"gzip\"
+dump_image_format = \"gzip\"
+
hugetlbfs_mount = \"/dev/hugepages\"
set_process_name = 1
--
1.7.2.3
14 years
[libvirt] [PATCH] qemu_driver: add virCgroupMounted
by Lai Jiangshan
When wen mount any cgroup without "-o devices", we will fail to start vms:
# virsh start vm1
error: Failed to start domain vm1
error: Unable to deny all devices for vm1: No such file or directory
When wen mount any cgroup without "-o cpu", we will fail to get schedinfo:
# virsh schedinfo vm1
Scheduler : posix
error: unable to get cpu shares tunable: No such file or directory
We should only use the cgroup controllers which are mounted on host.
So I add virCgroupMounted() for qemuCgroupControllerActive()
Signed-off-by: Lai Jiangshan <laijs(a)cn.fujitsu.com>
---
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3b127d6..5885ad8 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -61,6 +61,7 @@ virConfWriteMem;
# cgroup.h
virCgroupForDomain;
virCgroupForDriver;
+virCgroupMounted;
virCgroupRemove;
virCgroupFree;
virCgroupAddTask;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 16f34f7..f09d029 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -724,6 +724,8 @@ static int qemuCgroupControllerActive(struct qemud_driver *driver,
{
if (driver->cgroup == NULL)
return 0;
+ if (!virCgroupMounted(driver->cgroup, controller))
+ return 0;
if (driver->cgroupControllers & (1 << controller))
return 1;
return 0;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 7e887dc..8fac389 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -71,6 +71,17 @@ void virCgroupFree(virCgroupPtr *group)
VIR_FREE(*group);
}
+/**
+ * virCgroupMounted: query whether a cgroup subsystem is mounted or not
+ *
+ * @cgroup: The group structure to be queried
+ * @controller: cgroup subsystem id
+ */
+bool virCgroupMounted(virCgroupPtr cgroup, int controller)
+{
+ return !!cgroup->controllers[controller].mountPoint;
+}
+
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
/*
* Process /proc/mounts figuring out what controllers are
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index b8f2d08..9e1c61f 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -83,5 +83,6 @@ int virCgroupGetFreezerState(virCgroupPtr group, char **state);
int virCgroupRemove(virCgroupPtr group);
void virCgroupFree(virCgroupPtr *group);
+bool virCgroupMounted(virCgroupPtr cgroup, int controller);
#endif /* CGROUP_H */
14 years