[libvirt] question of kvm
by hero
I want to back up my VM including my own data, but the VM must be 'PASUED' or 'SHUT OFF' if I use 'virt-clone', I want to know how to back up my VM when it's running like make a ghost of windows.
Thansk!
SunYongGang
12 years, 10 months
[libvirt] [PATCH 0/4] virsh: Make more commands cancelable via ^C
by Michal Privoznik
Currently, only migration command allows job progress reporting
and cancel via SIGINT. However, there are more job oriented commands
which take long time to finish and user might want to cancel them
like he can do in migration. Such commands are: dump, save, managedsave.
Michal Privoznik (4):
virsh: Move job watch code to a separate function
virsh: Use do_job_watch in cmdDump
virsh: Use do_job_watch in cmdSave
virsh: Use do_job_watch in cmdManagedSave
tools/virsh.c | 425 +++++++++++++++++++++++++++++++++++++++++--------------
tools/virsh.pod | 24 ++--
2 files changed, 330 insertions(+), 119 deletions(-)
--
1.7.3.4
12 years, 10 months
[libvirt] [libvirt-glib 1/2] Add python example for LibvirtGConfig
by Christophe Fergeau
---
examples/config-test.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
create mode 100644 examples/config-test.py
diff --git a/examples/config-test.py b/examples/config-test.py
new file mode 100644
index 0000000..92e8a89
--- /dev/null
+++ b/examples/config-test.py
@@ -0,0 +1,96 @@
+#!/usr/bin/python
+
+from gi.repository import LibvirtGConfig;
+
+domain = LibvirtGConfig.Domain.new()
+domain.set_name("foo")
+domain.set_memory(1024*1024*1024)
+domain.set_vcpus(2)
+domain.set_lifecycle(LibvirtGConfig.DomainLifecycleEvent.ON_POWEROFF,
+ LibvirtGConfig.DomainLifecycleAction.DESTROY)
+
+clock = LibvirtGConfig.DomainClock.new()
+clock.set_offset(LibvirtGConfig.DomainClockOffset.UTC)
+domain.set_clock(clock)
+
+os = LibvirtGConfig.DomainOs.new()
+os.set_os_type(LibvirtGConfig.DomainOsType.HVM)
+os.set_arch("x86_64")
+devices = [ LibvirtGConfig.DomainOsBootDevice.CDROM,
+ LibvirtGConfig.DomainOsBootDevice.NETWORK ]
+os.set_boot_devices(devices)
+domain.set_os(os)
+
+disk = LibvirtGConfig.DomainDisk.new()
+disk.set_type(LibvirtGConfig.DomainDiskType.FILE)
+disk.set_guest_device_type(LibvirtGConfig.DomainDiskGuestDeviceType.DISK)
+disk.set_source("/tmp/foo/bar")
+disk.set_driver_name("qemu")
+disk.set_driver_type("qcow2")
+disk.set_target_bus(LibvirtGConfig.DomainDiskBus.IDE)
+disk.set_target_dev("hda")
+domain.add_device(disk)
+
+interface = LibvirtGConfig.DomainInterfaceNetwork.new()
+interface.set_source("default")
+domain.add_device(interface)
+
+interface = LibvirtGConfig.DomainInterfaceUser.new()
+interface.set_ifname("eth0")
+interface.set_link_state(LibvirtGConfig.DomainInterfaceLinkState.UP)
+interface.set_mac("00:11:22:33:44:55")
+interface.set_model("foo")
+domain.add_device(interface)
+
+input = LibvirtGConfig.DomainInput.new()
+input.set_device_type(LibvirtGConfig.DomainInputDeviceType.TABLET)
+input.set_bus(LibvirtGConfig.DomainInputBus.USB)
+domain.add_device(input)
+
+graphics = LibvirtGConfig.DomainGraphicsSpice.new()
+graphics.set_port(1234)
+domain.add_device(graphics)
+
+video = LibvirtGConfig.DomainVideo.new()
+video.set_model(LibvirtGConfig.DomainVideoModel.QXL)
+domain.add_device(video)
+
+console = LibvirtGConfig.DomainConsole.new()
+pty = LibvirtGConfig.DomainChardevSourcePty.new()
+console.set_source(pty)
+domain.add_device(console)
+
+print domain.to_xml()
+
+
+pool = LibvirtGConfig.StoragePool.new()
+pool.set_pool_type(LibvirtGConfig.StoragePoolType.DIR)
+
+pool_source = LibvirtGConfig.StoragePoolSource.new()
+pool_source.set_directory("/foo/bar")
+pool.set_source(pool_source)
+
+perms = LibvirtGConfig.StoragePermissions.new()
+perms.set_owner(1001)
+perms.set_group(1005)
+perms.set_mode(0744)
+perms.set_label("virt_image_t")
+
+pool_target = LibvirtGConfig.StoragePoolTarget.new()
+pool_target.set_path("/dev/disk/by-path")
+pool_target.set_permissions(perms)
+pool.set_target(pool_target)
+
+print pool.to_xml()
+
+
+vol = LibvirtGConfig.StorageVol.new()
+vol.set_name("my-vol")
+vol.set_capacity(0xdeadbeef)
+
+vol_target = LibvirtGConfig.StorageVolTarget.new()
+vol_target.set_format("qcow2")
+vol_target.set_permissions(perms)
+vol.set_target(vol_target)
+
+print vol.to_xml()
--
1.7.7.4
12 years, 10 months
[libvirt] [PATCH] qemu: Support readonly filesystem passthrough
by Osier Yang
Upstream QEMU starts to support it from commit 2c74c2cb.
---
docs/formatdomain.html.in | 5 +++--
src/qemu/qemu_capabilities.c | 7 ++++++-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 11 +++++++++++
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c57b7b3..9cf0f12 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1399,8 +1399,9 @@
<dt><code>readonly</code></dt>
<dd>
- An optional <code>readonly</code> attribute is available but currently
- unused.
+ Enables exporting filesytem as a readonly mount for guest, by
+ default read-write access is given (currently only works for
+ QEMU/KVM driver).
</dd>
</dl>
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index de2bc13..43c7578 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -143,6 +143,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"rombar",
"ich9-ahci",
"no-acpi",
+ "fsdev-readonly",
);
struct qemu_feature_flags {
@@ -981,6 +982,7 @@ qemuCapsComputeCmdFlags(const char *help,
virBitmapPtr flags)
{
const char *p;
+ const char *fsdev;
if (strstr(help, "-no-kqemu"))
qemuCapsSet(flags, QEMU_CAPS_KQEMU);
@@ -1077,8 +1079,11 @@ qemuCapsComputeCmdFlags(const char *help,
qemuCapsSet(flags, QEMU_CAPS_NESTING);
if (strstr(help, ",menu=on"))
qemuCapsSet(flags, QEMU_CAPS_BOOT_MENU);
- if (strstr(help, "-fsdev"))
+ if ((fsdev = strstr(help, "-fsdev"))) {
qemuCapsSet(flags, QEMU_CAPS_FSDEV);
+ if (strstr(fsdev, "readonly"))
+ qemuCapsSet(flags, QEMU_CAPS_FSDEV_READONLY);
+ }
if (strstr(help, "-smbios type"))
qemuCapsSet(flags, QEMU_CAPS_SMBIOS_TYPE);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 08d8457..c759baf 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -116,6 +116,7 @@ enum qemuCapsFlags {
QEMU_CAPS_PCI_ROMBAR = 76, /* -device rombar=0|1 */
QEMU_CAPS_ICH9_AHCI = 77, /* -device ich9-ahci */
QEMU_CAPS_NO_ACPI = 78, /* -no-acpi */
+ QEMU_CAPS_FSDEV_READONLY =79, /* -fsdev readonly supported */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9d3bc23..ea1b763 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2108,6 +2108,17 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
virBufferAsprintf(&opt, ",id=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
virBufferAsprintf(&opt, ",path=%s", fs->src);
+ if (fs->readonly) {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_FSDEV_READONLY)) {
+ virBufferAddLit(&opt, ",readonly");
+ } else {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("readonly filesystem is not supported by this "
+ "QEMU binary"));
+ goto error;
+ }
+ }
+
if (virBufferError(&opt)) {
virReportOOMError();
goto error;
--
1.7.7.3
12 years, 10 months
[libvirt] question on kvm
by hero
on redhat5.6 and redhat 6.1, I can got the MAC address of the kvm VMs,but I don't know how to get the ip address of the VMs,and virsh has not got a command,can you help me to resolve it.
12 years, 10 months
[libvirt] [PATCH] nwfilter: Do not require DHCP requests to be broadcast
by Stefan Berger
Remove the requirement that DHCP messages have to be broadcasted.
---
src/nwfilter/nwfilter_ebiptables_driver.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -3245,9 +3245,8 @@ ebtablesApplyDHCPOnlyRules(const char *i
virBufferAsprintf(&buf,
CMD_DEF("$EBT -t nat -A %s"
- " -s %s -d Broadcast "
+ " -s %s"
" -p ipv4 --ip-protocol udp"
- " --ip-src 0.0.0.0 --ip-dst 255.255.255.255"
" --ip-sport 68 --ip-dport 67"
" -j ACCEPT") CMD_SEPARATOR
CMD_EXEC
12 years, 10 months
[libvirt] [PATCH 0/4] RFC: grant KVM guests retain arbitrary capabilities
by Taku Izumi
Hi all,
This patchset adds an option for KVM guests to retain arbitrary capabilities.
I want KVM guests to retain "cap_sys_rawio" capability, so I tried to
run qemu as root user. However because libvirt clears all capability
of KVM guest by default, even if guest is running as root user,
it doesn't have any capability. I can fulfill my requirement by
disabling "clear_emulator_capabilities" option, but it's not
good idea considering security risk. I'm happy libvirt could clear
unnecessary capabilities instead of clearing all. That is a motivator
for creating this patch.
By adding "domain_capabilities" element and to domain XML, its domain
can retain specified capabilities like the following:
; VM can retain cap_sys_rawio capability
# virsh edit VM
...
</features>
<domain_capabilities>
<cap_sys_rawio/>
</domain_capabilities>
<clock offset='utc'/>
...
# virsh start VM
# cat /proc/<VM's PID/status
...
CapInh: 0000000000000000
CapPrm: fffffffc00020000
CapEff: fffffffc00020000
CapBnd: fffffffc00020000
...
*[PATCH 1/4] conf: add XML schema for domain capabilities
*[PATCH 2/4] util: add functions to keep capabilities
*[PATCH 3/4] util: extend virExecWithHook()
*[PATCH 4/4] qemu: make qemu processes to retain capabilities
--
Best regards,
Taku Izumi <izumi.taku(a)jp.fujitsu.com>
12 years, 10 months
[libvirt] [PATCH 1/4] Make drive unit attribute optional in the XML schema
by Michael Ellerman
The "unit" attribute of a drive address is optional in the code, so should
also be in the XML schema.
Signed-off-by: Michael Ellerman <michael(a)ellerman.id.au>
---
docs/schemas/domaincommon.rng | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 553a6f0..f35eb0b 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2241,9 +2241,11 @@
<ref name="driveBus"/>
</attribute>
</optional>
- <attribute name="unit">
- <ref name="driveUnit"/>
- </attribute>
+ <optional>
+ <attribute name="unit">
+ <ref name="driveUnit"/>
+ </attribute>
+ </optional>
</define>
<define name="virtioserialaddress">
<attribute name="controller">
--
1.7.7.3
12 years, 10 months
[libvirt] [PATCH] qemu: Release the lock on domobj if fails on finding the disk path
by Osier Yang
---
src/qemu/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 660d771..c156794 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7181,7 +7181,7 @@ qemuDomainBlockResize (virDomainPtr dom,
if ((i = virDomainDiskIndexByName(vm->def, path, false)) < 0) {
qemuReportError(VIR_ERR_INVALID_ARG,
_("invalid path: %s"), path);
- goto cleanup;
+ goto endjob;
}
disk = vm->def->disks[i];
--
1.7.7.3
12 years, 10 months
[libvirt] [PATCH 1/6] Add address type for SPAPR VIO devices
by Michael Ellerman
For QEMU PPC64 we have a machine type ("pseries") which has a virtual
bus called "spapr-vio". We need to be able to create devices on this
bus, and as such need a way to specify the address for those devices.
This patch adds a new address type "spapr-vio", which achieves this.
The addressing is specified with a "reg" property in the address
definition. The reg is optional, if it is not specified QEMU will
auto-assign an address for the device.
Signed-off-by: Michael Ellerman <michael(a)ellerman.id.au>
---
src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
src/conf/domain_conf.h | 9 +++++++++
src/qemu/qemu_command.c | 5 +++++
3 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d68ab10..8dfcebc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -139,7 +139,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
"drive",
"virtio-serial",
"ccid",
- "usb")
+ "usb",
+ "spapr-vio")
VIR_ENUM_IMPL(virDomainDeviceAddressPciMulti,
VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST,
@@ -1909,6 +1910,11 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
info->addr.usb.port);
break;
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
+ if (info->addr.spaprvio.has_reg)
+ virBufferAsprintf(buf, " reg='0x%llx'", info->addr.spaprvio.reg);
+ break;
+
default:
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown address type '%d'"), info->type);
@@ -2168,6 +2174,34 @@ cleanup:
}
static int
+virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node,
+ virDomainDeviceSpaprVioAddressPtr addr)
+{
+ char *reg;
+ int ret;
+
+ memset(addr, 0, sizeof(*addr));
+ addr->has_reg = false;
+
+ reg = virXMLPropString(node, "reg");
+ if (reg) {
+ if (virStrToLong_ull(reg, NULL, 16, &addr->reg) < 0) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <address> 'reg' attribute"));
+ ret = -1;
+ goto cleanup;
+ }
+
+ addr->has_reg = true;
+ }
+
+ ret = 0;
+cleanup:
+ VIR_FREE(reg);
+ return ret;
+}
+
+static int
virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
virDomainDeviceUSBMasterPtr master)
{
@@ -2280,6 +2314,11 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
goto cleanup;
break;
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
+ if (virDomainDeviceSpaprVioAddressParseXML(address, &info->addr.spaprvio) < 0)
+ goto cleanup;
+ break;
+
default:
/* Should not happen */
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3174,6 +3213,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
}
if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Controllers must use the 'pci' address type"));
@@ -3566,6 +3606,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
/* XXX what about ISA/USB based NIC models - once we support
* them we should make sure address type is correct */
if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Network interfaces must use 'pci' address type"));
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d6ed898..0ed6aba 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -69,6 +69,7 @@ enum virDomainDeviceAddressType {
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
};
@@ -121,6 +122,13 @@ struct _virDomainDeviceUSBAddress {
char *port;
};
+typedef struct _virDomainDeviceSpaprVioAddress virDomainDeviceSpaprVioAddress;
+typedef virDomainDeviceSpaprVioAddress *virDomainDeviceSpaprVioAddressPtr;
+struct _virDomainDeviceSpaprVioAddress {
+ unsigned long long reg;
+ bool has_reg;
+};
+
enum virDomainControllerMaster {
VIR_DOMAIN_CONTROLLER_MASTER_NONE,
VIR_DOMAIN_CONTROLLER_MASTER_USB,
@@ -145,6 +153,7 @@ struct _virDomainDeviceInfo {
virDomainDeviceVirtioSerialAddress vioserial;
virDomainDeviceCcidAddress ccid;
virDomainDeviceUSBAddress usb;
+ virDomainDeviceSpaprVioAddress spaprvio;
} addr;
int mastertype;
union {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d33d7c8..7128b18 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1256,6 +1256,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr addrs)
def->controllers[i]->idx == 0)
continue;
+ if (def->controllers[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
+ continue;
if (def->controllers[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
continue;
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->controllers[i]->info) < 0)
@@ -1406,6 +1408,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
virBufferAsprintf(buf, ",bus=");
qemuUsbId(buf, info->addr.usb.bus);
virBufferAsprintf(buf, ".0,port=%s", info->addr.usb.port);
+ } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
+ if (info->addr.spaprvio.has_reg)
+ virBufferAsprintf(buf, ",reg=0x%llx", info->addr.spaprvio.reg);
}
return 0;
--
1.7.7.3
12 years, 10 months