[libvirt] Fwd: Re: [virt-tools-list] Lilo succeeds with kvm but not virt-manager
by Richard W.M. Jones
Forwarding to libvir-list ...
Rich.
----- Forwarded message from Daniel Janzon <daniel.janzon(a)edgeware.tv> -----
Subject: Re: [virt-tools-list] Lilo succeeds with kvm but not virt-manager
Date: Mon, 07 Jun 2010 10:56:29 +0200
From: Daniel Janzon <>
To: virt-tools-list
On 06/05/2010 06:00 PM, virt-tools-list-request(a)redhat.com wrote:
> Message: 1
> Date: Fri, 4 Jun 2010 17:55:17 +0100
> From: "Richard W.M. Jones"<rjones(a)redhat.com>
> To: Daniel Janzon<daniel.janzon(a)edgeware.tv>
> Cc: virt-tools-list(a)redhat.com
> Subject: Re: [virt-tools-list] Lilo bootloader succeeds with kvm but
> not virt-manager
> Message-ID:<20100604165517.GA4612(a)amd.home.annexia.org>
> Content-Type: text/plain; charset=us-ascii
>
> On Fri, Jun 04, 2010 at 02:03:12PM +0200, Daniel Janzon wrote:
>
>> I installed Linux Suse as a guest in virt-manager/KVM and had trouble to
>> install grub. So I used good old Lilo instead. When running Suse in
>> virt-manager Lilo fails with
>>
>> LILO - Keytable read/checksum error on bootup
>>
>> When I go
>>
>> kvm -m 512 -hda SLES-10.3.img
>>
> libvirt won't have such a simple command line. There could be other
> KVM options which affect things at boot.
>
> I have a couple of suggestions:
>
> (1) Find out the full libvirt command line. Easiest is to start the
> domain under virt-manager and quickly use the 'ps ax' command. (There
> is a more "official" way to convert libvirt XML into a qemu command
> line but I cannot recall what that is at the moment).
>
Smart! I did that and found out that it is the boot=on drive option that
is the cause of the problem:
-drive file=/root/SLES-10.3.img,if=ide,index=0,boot=on
For some reason it only works when it is set to boot=off. I tried
<boot>off</boot> and boot="off" in the target tag in the corresponding
disk tag in the XML file, but with no luck. I also tried to remove the
<boot dev='hd'/> from the os tag. I did do a "/etc/init.d/libvirt-bin
reload" just in case. Is there any way to get control the boot option from
the XML file?
> (2) Use virt-rescue or guestfish and see if you can install grub in
> the domain. In guestfish it'd be something like this:
>
> guestfish -i GuestName
> ><fs> mkdir-p /boot/grub
> ><fs> grub-install /boot /dev/sda1
>
> (You might need to change those command slightly and read the man page
> for virt-rescue, guestfish and/or grub-install).
>
Ok, thanks for the tip. I will consider it if it impossible to control the
boot option as explained above. Or maybe I'll just settle with being
annoyed and start the machine from the command line :)
All the best,
Daniel Janzon
_______________________________________________
virt-tools-list mailing list
virt-tools-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list
----- End forwarded message -----
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
14 years, 5 months
[libvirt] [PATCH] 0/10AppArmor driver updates
by Jamie Strandboge
This patch series addresses bug fixes in the AppArmor driver as well as
updating it to changes made in 0.7.6 and 0.7.7. All of these are
self-contained within the driver except 4_qemu_driver_stdin_path.patch.
This is required by 5_apparmor-fix-save-restore.patch (see below). These
all pass 'make syntax-check' and 'make check' (except 'daemon-conf',
which has never passed here and I didn't patch it).
1_apparmor-dont-clear-caps.patch: originally submitted on 2010/02/08
with no feedback. The calls to virExec() in security_apparmor.c when
invoking virt-aa-helper use VIR_EXEC_CLEAR_CAPS. When compiled without
libcap-ng, this is not a problem (it's effectively a no-op) but with
libcap-ng this causes MAC_ADMIN to be cleared. MAC_ADMIN is needed by
virt-aa-helper to manipulate apparmor profiles and without it VMs will
not start[1]. This patch calls virExec with the default VIR_EXEC_NONE
instead.
2_apparmor-remove-unloaded-profile-is-not-fatal.patch: Don't exit with
error if the user unloaded the profile outside of libvirt[2]
3_apparmor-fix-vah-xml-parse.patch: add VIR_DOMAIN_XML_INACTIVE flag to
virDomainDefParseString() so virDomainDefParseString() doesn't error out
when seeing <seclabel...>. This was needed due to changes since 0.7.5.
4_qemu_driver_stdin_path.patch: adjust args to qemudStartVMDaemon() to
also specify path to stdin_fd, so this can be passed to the AppArmor
driver via *SetSecurityAllLabel(). This updates all calls to
qemudStartVMDaemon() as well as setting up the non-AppArmor security
driver *SetSecurityAllLabel() declarations for the above. This is
required for 5_apparmor-fix-save-restore.patch since AppArmor resolves
the passed file descriptor to the pathname given to open().
5_apparmor-fix-save-restore.patch: refactoring to update AppArmor
security driver to adjust profile for save/restore[3]
6_apparmor-fix-backingstore.patch: adjust virt-aa-helper to handle
backing store[4]
7_apparmor-fix-hostdev.patch: adjust virt-aa-helper to handle pci
devices. Update valid_path() to have an override array to check against,
and add "/sys/devices/pci" to it. Then rename file_iterate_cb() to
file_iterate_hostdev_cb() and create file_iterate_pci_cb() based on it.
8_apparmor-fix-xauth.patch: adjust virt-aa-helper to handle SDL
graphics, specifically Xauthority[6]. Also remove a couple redundant
checks
9_apparmor-examples.patch: adjustments to the example profiles
10_apparmor-vah-test.patch: update pcidev test and add SDL xauth
[1] https://launchpad.net/bugs/517714
[2] https://launchpad.net/bugs/530400
[3] https://launchpad.net/bugs/457716
[4] https://launchpad.net/bugs/470636
[5] https://launchpad.net/bugs/545795
[6] https://launchpad.net/bugs/545426
--
Jamie Strandboge | http://www.canonical.com
14 years, 5 months
Re: [libvirt] [PATCH] 4/10 AppArmor driver updates
by Laine Stump
Jamie,
This patch was ACKed but somehow never pushed. Is it still
okay to push it as is?
On Mon, 2010-04-05 at 16:15 -0500, Jamie Strandboge wrote:
> 4_qemu_driver_stdin_path.patch: adjust args to qemudStartVMDaemon() to
> also specify path to stdin_fd, so this can be passed to the AppArmor
> driver via *SetSecurityAllLabel(). This updates all calls to
> qemudStartVMDaemon() as well as setting up the non-AppArmor security
> driver *SetSecurityAllLabel() declarations for the above. This is
> required for 5_apparmor-fix-save-restore.patch since AppArmor resolves
> the passed file descriptor to the pathname given to open().
--
Jamie Strandboge | http://www.canonical.com
diff -Naur libvirt.orig/src/qemu/qemu_driver.c libvirt/src/qemu/qemu_driver.c
--- libvirt.orig/src/qemu/qemu_driver.c 2010-04-05 13:07:44.000000000 -0500
+++ libvirt/src/qemu/qemu_driver.c 2010-04-05 14:16:20.000000000 -0500
@@ -148,7 +148,8 @@
struct qemud_driver *driver,
virDomainObjPtr vm,
const char *migrateFrom,
- int stdin_fd);
+ int stdin_fd,
+ const char *stdin_path);
static void qemudShutdownVMDaemon(struct qemud_driver *driver,
virDomainObjPtr vm);
@@ -629,7 +630,7 @@
int ret;
virResetLastError();
- ret = qemudStartVMDaemon(data->conn, data->driver, vm, NULL, -1);
+ ret = qemudStartVMDaemon(data->conn, data->driver, vm, NULL, -1, NULL);
if (ret < 0) {
virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
@@ -3145,7 +3146,8 @@
struct qemud_driver *driver,
virDomainObjPtr vm,
const char *migrateFrom,
- int stdin_fd) {
+ int stdin_fd,
+ const char *stdin_path) {
const char **argv = NULL, **tmp;
const char **progenv = NULL;
int i, ret;
@@ -3193,7 +3195,7 @@
DEBUG0("Generating setting domain security labels (if required)");
if (driver->securityDriver &&
driver->securityDriver->domainSetSecurityAllLabel &&
- driver->securityDriver->domainSetSecurityAllLabel(vm) < 0)
+ driver->securityDriver->domainSetSecurityAllLabel(vm, stdin_path) < 0)
goto cleanup;
/* Ensure no historical cgroup for this VM is lying around bogus
@@ -4054,7 +4056,7 @@
if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup; /* XXXX free the 'vm' we created ? */
- if (qemudStartVMDaemon(conn, driver, vm, NULL, -1) < 0) {
+ if (qemudStartVMDaemon(conn, driver, vm, NULL, -1, NULL) < 0) {
if (qemuDomainObjEndJob(vm) > 0)
virDomainRemoveInactive(&driver->domains,
vm);
@@ -5909,7 +5911,7 @@
}
}
/* Set the migration source and start it up. */
- ret = qemudStartVMDaemon(conn, driver, vm, "stdio", fd);
+ ret = qemudStartVMDaemon(conn, driver, vm, "stdio", fd, path);
if (intermediate_pid != -1) {
/* Wait for intermediate process to exit */
while (waitpid(intermediate_pid, &childstat, 0) == -1 &&
@@ -6334,7 +6336,7 @@
virDomainObjLock(vm);
}
- ret = qemudStartVMDaemon(dom->conn, driver, vm, NULL, -1);
+ ret = qemudStartVMDaemon(dom->conn, driver, vm, NULL, -1, NULL);
if (ret != -1)
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STARTED,
@@ -9400,7 +9402,7 @@
/* Start the QEMU daemon, with the same command-line arguments plus
* -incoming unix:/path/to/file or exec:nc -U /path/to/file
*/
- internalret = qemudStartVMDaemon(dconn, driver, vm, migrateFrom, -1);
+ internalret = qemudStartVMDaemon(dconn, driver, vm, migrateFrom, -1, NULL);
VIR_FREE(migrateFrom);
if (internalret < 0) {
/* Note that we don't set an error here because qemudStartVMDaemon
@@ -9605,7 +9607,7 @@
* -incoming tcp:0.0.0.0:port
*/
snprintf (migrateFrom, sizeof (migrateFrom), "tcp:0.0.0.0:%d", this_port);
- if (qemudStartVMDaemon (dconn, driver, vm, migrateFrom, -1) < 0) {
+ if (qemudStartVMDaemon (dconn, driver, vm, migrateFrom, -1, NULL) < 0) {
/* Note that we don't set an error here because qemudStartVMDaemon
* should have already done that.
*/
@@ -11027,7 +11029,7 @@
goto cleanup;
rc = qemudStartVMDaemon(snapshot->domain->conn, driver, vm, NULL,
- -1);
+ -1, NULL);
if (qemuDomainSnapshotSetInactive(vm, driver->snapshotDir) < 0)
goto cleanup;
if (rc < 0)
diff -Naur libvirt.orig/src/qemu/qemu_security_dac.c libvirt/src/qemu/qemu_security_dac.c
--- libvirt.orig/src/qemu/qemu_security_dac.c 2010-03-24 11:44:19.000000000 -0500
+++ libvirt/src/qemu/qemu_security_dac.c 2010-04-05 14:14:43.000000000 -0500
@@ -346,7 +346,7 @@
static int
-qemuSecurityDACSetSecurityAllLabel(virDomainObjPtr vm)
+qemuSecurityDACSetSecurityAllLabel(virDomainObjPtr vm, const char *stdin_path ATTRIBUTE_UNUSED)
{
int i;
diff -Naur libvirt.orig/src/qemu/qemu_security_stacked.c libvirt/src/qemu/qemu_security_stacked.c
--- libvirt.orig/src/qemu/qemu_security_stacked.c 2010-03-03 07:07:33.000000000 -0600
+++ libvirt/src/qemu/qemu_security_stacked.c 2010-04-05 14:14:43.000000000 -0500
@@ -196,18 +196,18 @@
static int
-qemuSecurityStackedSetSecurityAllLabel(virDomainObjPtr vm)
+qemuSecurityStackedSetSecurityAllLabel(virDomainObjPtr vm, const char *stdin_path)
{
int rc = 0;
if (driver->securitySecondaryDriver &&
driver->securitySecondaryDriver->domainSetSecurityAllLabel &&
- driver->securitySecondaryDriver->domainSetSecurityAllLabel(vm) < 0)
+ driver->securitySecondaryDriver->domainSetSecurityAllLabel(vm, stdin_path) < 0)
rc = -1;
if (driver->securityPrimaryDriver &&
driver->securityPrimaryDriver->domainSetSecurityAllLabel &&
- driver->securityPrimaryDriver->domainSetSecurityAllLabel(vm) < 0)
+ driver->securityPrimaryDriver->domainSetSecurityAllLabel(vm, stdin_path) < 0)
rc = -1;
return rc;
diff -Naur libvirt.orig/src/security/security_driver.h libvirt/src/security/security_driver.h
--- libvirt.orig/src/security/security_driver.h 2010-03-24 11:44:19.000000000 -0500
+++ libvirt/src/security/security_driver.h 2010-04-05 14:14:43.000000000 -0500
@@ -45,7 +45,8 @@
typedef int (*virSecurityDomainGenLabel) (virDomainObjPtr sec);
typedef int (*virSecurityDomainReserveLabel) (virDomainObjPtr sec);
typedef int (*virSecurityDomainReleaseLabel) (virDomainObjPtr sec);
-typedef int (*virSecurityDomainSetAllLabel) (virDomainObjPtr sec);
+typedef int (*virSecurityDomainSetAllLabel) (virDomainObjPtr sec,
+ const char *stdin_path);
typedef int (*virSecurityDomainRestoreAllLabel) (virDomainObjPtr vm);
typedef int (*virSecurityDomainGetProcessLabel) (virDomainObjPtr vm,
virSecurityLabelPtr sec);
diff -Naur libvirt.orig/src/security/security_selinux.c libvirt/src/security/security_selinux.c
--- libvirt.orig/src/security/security_selinux.c 2010-04-05 13:07:44.000000000 -0500
+++ libvirt/src/security/security_selinux.c 2010-04-05 14:14:43.000000000 -0500
@@ -722,7 +722,7 @@
}
static int
-SELinuxSetSecurityAllLabel(virDomainObjPtr vm)
+SELinuxSetSecurityAllLabel(virDomainObjPtr vm, const char *stdin_path ATTRIBUTE_UNUSED)
{
const virSecurityLabelDefPtr secdef = &vm->def->seclabel;
int i;
14 years, 5 months
[libvirt] make syntax-check error due to bad email addr
by Justin Clift
Hi all,
make syntax-check is reporting an error with the AUTHORS file, which
seems to be coming from an incorrect address for Jim Fehlig.
$ make syntax-check
GFDL_version
2.60 GFDL_version
TAB_in_indentation
0.03 TAB_in_indentation
Wundef_boolean
0.25 Wundef_boolean
avoid_ctype_macros
0.14 avoid_ctype_macros
avoid_if_before_free
7.60 avoid_if_before_free
avoid_write
0.03 avoid_write
cast_of_argument_to_free
0.12 cast_of_argument_to_free
cast_of_x_alloc_return_value
0.11 cast_of_x_alloc_return_value
changelog
0.02 changelog
check_author_list
jfehlig(a)linux-ypgk.site
maint.mk: committer(s) not listed in AUTHORS
make: *** [sc_check_author_list] Error 1
$
This is the git log entry it may be from:
commit b1eb7f2e987d21b1711e86e5cb63a69abfce82f1
Author: Jim Fehlig <jfehlig(a)linux-ypgk.site>
Date: Fri Jun 4 10:04:03 2010 -0600
Fixes for commit 211dd1e9
Fixes for issues in commit 211dd1e9 noted by by Jim Meyering.
1. Allocate content buffer of size content_length + 1 to ensure
NUL-termination.
2. Limit content buffer size to 64k
3. Fix whitespace issue
V2:
- Add comment to clarify allocation of content buffer
- Add ATTRIBUTE_NONNULL where appropriate
- User NULLSTR macro
Adding the incorrect email to the AUTHORS file is a workaround, but is
someone ok to fix the cause?
Regards and best wishes,
Justin Clift
--
Salasaga - Open Source eLearning IDE
http://www.salasaga.org
14 years, 5 months
[libvirt] [PATCH] Added snapshot backing store parameters to virsh vol-create-as.
by Justin Clift
---
tools/virsh.c | 52
+++++++++++++++++++++++++++++++++++++++++++++++++++-
tools/virsh.pod | 7 ++++++-
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1279f41..3ba549b 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5274,6 +5274,8 @@ static const vshCmdOptDef opts_vol_create_as[] = {
{"capacity", VSH_OT_DATA, VSH_OFLAG_REQ, N_("size of the vol with
optional k,M,G,T suffix")},
{"allocation", VSH_OT_STRING, 0, N_("initial allocation size with
optional k,M,G,T suffix")},
{"format", VSH_OT_STRING, 0, N_("file format type
raw,bochs,qcow,qcow2,vmdk")},
+ {"snapshot-source-vol", VSH_OT_STRING, 0, N_("the source volume if
taking a snapshot")},
+ {"snapshot-source-format", VSH_OT_STRING, 0, N_("format of the
source volume if taking a snapshot")},
{NULL, 0, 0, NULL}
};
@@ -5313,6 +5315,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
int found;
char *xml;
char *name, *capacityStr, *allocationStr, *format;
+ char *snapshotStrVol, *snapshotStrFormat;
unsigned long long capacity, allocation = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -5339,6 +5342,8 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, _("Malformed size %s"), allocationStr);
format = vshCommandOptString(cmd, "format", &found);
+ snapshotStrVol = vshCommandOptString(cmd, "snapshot-source-vol",
&found);
+ snapshotStrFormat = vshCommandOptString(cmd,
"snapshot-source-format", &found);
virBufferAddLit(&buf, "<volume>\n");
virBufferVSprintf(&buf, " <name>%s</name>\n", name);
@@ -5351,8 +5356,53 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
virBufferVSprintf(&buf, " <format type='%s'/>\n",format);
virBufferAddLit(&buf, " </target>\n");
}
- virBufferAddLit(&buf, "</volume>\n");
+ // Convert the snapshot parameters into backingStore XML
+ if (snapshotStrVol) {
+ // Use the name of the snapshot source volume to retrieve its
device path
+ vshDebug(ctl, 5, "%s: Looking up backing store volume '%s' as
name\n", cmd->def->name, snapshotStrVol);
+ virStorageVolPtr snapVol = virStorageVolLookupByName(pool,
snapshotStrVol);
+ if (snapVol)
+ vshDebug(ctl, 5, "%s: Backing store volume found using
'%s' as name\n", cmd->def->name, snapshotStrVol);
+
+ if (snapVol == NULL) {
+ // Snapshot source volume was not found by name. Try using
the snapshot-source-vol parameter as a key
+ vshDebug(ctl, 5, "%s: Looking up backing store volume '%s'
as key\n", cmd->def->name, snapshotStrVol);
+ snapVol = virStorageVolLookupByKey(ctl->conn, snapshotStrVol);
+ if (snapVol)
+ vshDebug(ctl, 5, "%s: Backing store volume found using
'%s' as key\n", cmd->def->name, snapshotStrVol);
+ }
+ if (snapVol == NULL) {
+ // Snapshot source volume was not found by key either. Try
using the snapshot-source-vol parameter as a path
+ vshDebug(ctl, 5, "%s: Looking up backing store volume '%s'
by path\n", cmd->def->name, snapshotStrVol);
+ snapVol = virStorageVolLookupByPath(ctl->conn, snapshotStrVol);
+ if (snapVol)
+ vshDebug(ctl, 5, "%s: Backing store volume found using
'%s' as path\n", cmd->def->name, snapshotStrVol);
+ }
+ if (snapVol == NULL) {
+ vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);
+ return FALSE;
+ }
+
+ char *snapshotStrVolPath;
+ if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
+ virStorageVolFree(snapVol);
+ return FALSE;
+ }
+
+ // Create the XML for the backing store
+ virBufferAddLit(&buf, " <backingStore>\n");
+ virBufferVSprintf(&buf, "
<path>%s</path>\n",snapshotStrVolPath);
+ if (snapshotStrFormat)
+ virBufferVSprintf(&buf, " <format
type='%s'/>\n",snapshotStrFormat);
+ virBufferAddLit(&buf, " </backingStore>\n");
+
+ // Cleanup snapshot allocations
+ VIR_FREE(snapshotStrVolPath);
+ virStorageVolFree(snapVol);
+ }
+
+ virBufferAddLit(&buf, "</volume>\n");
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
diff --git a/tools/virsh.pod b/tools/virsh.pod
index cab931c..b1a8544 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -782,7 +782,8 @@ source volume is in.
I<vol-name-or-key> is the name or UUID of the source volume.
=item B<vol-create-as> I<pool-or-uuid> I<name> I<capacity> optional
-I<--allocation> I<size> I<--format> I<string>
+I<--allocation> I<size> I<--format> I<string> I<--snapshot-source-vol>
I<vol-name-or-key>
+I<--snapshot-source-format> I<string>
Create a volume from a set of arguments.
I<pool-or-uuid> is the name or UUID of the storage pool to create the
volume
@@ -794,6 +795,10 @@ I<--allocation> I<size> is the initial size to be
allocated in the volume, with
optional k, M, G, or T suffix.
I<--format> I<string> is used in file based storage pools to specify
the volume
file format to use; raw, bochs, qcow, qcow2, vmdk.
+I<--snapshot-source-vol> I<vol-name-or-key> is the source backing
volume to be used if
+taking a snapshot of an existing volume.
+I<--snapshot-source-format> I<string> is the format of the snapshot
backing volume;
+raw, bochs, qcow, qcow2, vmdk.
=item B<vol-clone> [optional I<--pool> I<pool-or-uuid>]
I<vol-name-or-key> I<name>
-- 1.7.0.1
14 years, 5 months
[libvirt] [PATCH] Adds the missing vol-pool command to virsh. Now when given only a volume key or path, the complete pool+volume_name can be determined easily.
by Justin Clift
---
tools/virsh.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1279f41..95aea0f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5975,6 +5975,53 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
}
+/*
+ * "vol-pool" command
+ */
+static const vshCmdInfo info_vol_pool[] = {
+ {"help", N_("returns the storage pool for a given volume key or
path")},
+ {"desc", ""},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_vol_pool[] = {
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume key or path")},
+ {NULL, 0, 0, NULL}
+};
+
+static int
+cmdVolPool(vshControl *ctl, const vshCmd *cmd)
+{
+ virStoragePoolPtr pool;
+ virStorageVolPtr vol;
+
+ // Check the connection to libvirtd daemon is still working
+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
+ return FALSE;
+
+ // Use the supplied string to locate the volume
+ if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
+ VSH_BYUUID))) {
+ return FALSE;
+ }
+
+ // Look up the parent storage pool for the volume
+ pool = virStoragePoolLookupByVolume(vol);
+ if (pool == NULL) {
+ vshError(ctl, "%s", _("failed to get parent pool"));
+ virStorageVolFree(vol);
+ return FALSE;
+ }
+
+ // Return the name of the parent storage pool
+ vshPrint(ctl, "%s\n", virStoragePoolGetName(pool));
+
+ // Cleanup
+ virStorageVolFree(vol);
+ virStoragePoolFree(pool);
+ return TRUE;
+}
+
/*
* "vol-key" command
@@ -8837,6 +8884,7 @@ static const vshCmdDef commands[] = {
{"vol-dumpxml", cmdVolDumpXML, opts_vol_dumpxml, info_vol_dumpxml},
{"vol-info", cmdVolInfo, opts_vol_info, info_vol_info},
{"vol-list", cmdVolList, opts_vol_list, info_vol_list},
+ {"vol-pool", cmdVolPool, opts_vol_pool, info_vol_pool},
{"vol-path", cmdVolPath, opts_vol_path, info_vol_path},
{"vol-name", cmdVolName, opts_vol_name, info_vol_name},
{"vol-key", cmdVolKey, opts_vol_key, info_vol_key},
--
1.7.0.1
14 years, 5 months
[libvirt] VM/Domain "Start" method in libvirt API
by IKI-サガル バルウェ
Hi,
I was referring to the libvirt API reference from the foll link:
http://www.libvirt.org/html/libvirt-libvirt.html
There are functions for Suspending, ShuttingDown or Rebooting the VM like
virDomainSuspend, virDomainShutdown or virDomainReboot respectively.
But I did not find any method for starting a particular domain/VM like
virDomainStart.
There is a function in virsh for doing the same:
virsh start <domain> [--console]
Is there any other alternative method for "starting"a given domain??
Thanks and Regards
Sagar Barve
14 years, 5 months
[libvirt] Remote connection with libvirt
by IKI-サガル バルウェ
Hi,
I know this question has been asked a few times before, but I am not able to
connect to my xen hypervisor using a remote uri.
Here is how I access it:
virsh -c xen://hostname/ list --all
Here is the error:
libvir: Remote error : server certificate failed validation: The certificate
is not trusted.
libvir: Remote error : unable to connect to 'domain0.localdomain': Invalid
argument
Here is the log output:
09:36:17.124: error : remoteCheckCertificate: the client certificate is not
trusted.
09:36:17.124: error : remoteCheckCertificate: failed to verify client's
certificate
09:36:17.124: error : gnutls_record_recv: A TLS packet with unexpected
length was received.
I was able to connect using xen+tcp as follows:
virsh -c xen+tcp://hostname/ list --all
which gives me the expected list of VMs.
I am using libvirt version: libvirtd (libvirt) 0.6.3
I created the tls certificates by foll the instrucstions given here:
http://libvirt.org/remote.html#Remote_certificates
I have a few questions regarding them:
1. While setting up CA, in the ca.info file, what do the options "ca" and
"cert_signing_key" mean?
2. While setting up server certificate, in the "server.info" file I added
"cn=domain0.localdomain". because output of
"virsh hostname" is "domain0.localdomain", I am correct in doing this?
3. In "libvirtd.conf" file, what does the option "listen_addr" exactly mean?
Thanks and Regards,
Sagar Barve
14 years, 5 months
[libvirt] [PATCH] Added --pool support to virsh vol-key, plus improved help descriptions for vol-key, vol-name, & vol-path.
by Justin Clift
---
tools/virsh.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 3ba549b..2ac6e73 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5997,13 +5997,13 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd
ATTRIBUTE_UNUSED)
* "vol-name" command
*/
static const vshCmdInfo info_vol_name[] = {
- {"help", N_("convert a vol UUID to vol name")},
+ {"help", N_("returns the volume name for a given volume key or path")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_name[] = {
- {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol key or path")},
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume key or path")},
{NULL, 0, 0, NULL}
};
@@ -6025,18 +6025,18 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
}
-
/*
* "vol-key" command
*/
static const vshCmdInfo info_vol_key[] = {
- {"help", N_("convert a vol UUID to vol key")},
+ {"help", N_("returns the volume key for a given volume name or path")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_key[] = {
- {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol uuid")},
+ {"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume name or path")},
{NULL, 0, 0, NULL}
};
@@ -6044,12 +6044,12 @@ static int
cmdVolKey(vshControl *ctl, const vshCmd *cmd)
{
virStorageVolPtr vol;
+ char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
- if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", "pool", NULL,
- VSH_BYUUID)))
+ if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name)))
return FALSE;
vshPrint(ctl, "%s\n", virStorageVolGetKey(vol));
@@ -6058,19 +6058,18 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd)
}
-
/*
* "vol-path" command
*/
static const vshCmdInfo info_vol_path[] = {
- {"help", N_("convert a vol UUID to vol path")},
+ {"help", N_("returns the volume path for a given volume name or key")},
{"desc", ""},
{NULL, NULL}
};
static const vshCmdOptDef opts_vol_path[] = {
{"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
- {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("vol name or key")},
+ {"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("volume name or key")},
{NULL, 0, 0, NULL}
};
-- 1.7.0.1
14 years, 5 months
[libvirt] [PATCH] Added snapshot backing store parameters to virsh.
by Justin Clift
---
tools/virsh.c | 32 +++++++++++++++++++++++++++++++-
tools/virsh.pod | 7 ++++++-
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1279f41..04d38b7 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5274,6 +5274,8 @@ static const vshCmdOptDef opts_vol_create_as[] = {
{"capacity", VSH_OT_DATA, VSH_OFLAG_REQ, N_("size of the vol with
optional k,M,G,T suffix")},
{"allocation", VSH_OT_STRING, 0, N_("initial allocation size with
optional k,M,G,T suffix")},
{"format", VSH_OT_STRING, 0, N_("file format type
raw,bochs,qcow,qcow2,vmdk")},
+ {"snapshot-source-vol", VSH_OT_STRING, 0, N_("the source volume if
taking a snapshot")},
+ {"snapshot-source-format", VSH_OT_STRING, 0, N_("format of the
source volume if taking a snapshot")},
{NULL, 0, 0, NULL}
};
@@ -5313,6 +5315,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
int found;
char *xml;
char *name, *capacityStr, *allocationStr, *format;
+ char *snapshotStrVol, *snapshotStrFormat;
unsigned long long capacity, allocation = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -5339,6 +5342,8 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, _("Malformed size %s"), allocationStr);
format = vshCommandOptString(cmd, "format", &found);
+ snapshotStrVol = vshCommandOptString(cmd, "snapshot-source-vol",
&found);
+ snapshotStrFormat = vshCommandOptString(cmd,
"snapshot-source-format", &found);
virBufferAddLit(&buf, "<volume>\n");
virBufferVSprintf(&buf, " <name>%s</name>\n", name);
@@ -5351,8 +5356,33 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
virBufferVSprintf(&buf, " <format type='%s'/>\n",format);
virBufferAddLit(&buf, " </target>\n");
}
- virBufferAddLit(&buf, "</volume>\n");
+ // Convert the snapshot parameters into backingStore XML
+ if (snapshotStrVol) {
+ // Use the name of the snapshot source volume to retrieve its
device path
+ virStorageVolPtr snapVol = virStorageVolLookupByName(pool,
snapshotStrVol);
+ if (snapVol == NULL) {
+ return FALSE;
+ }
+ char *snapshotStrVolPath;
+ if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
+ virStorageVolFree(snapVol);
+ return FALSE;
+ }
+
+ // Create the XML for the backing store
+ virBufferAddLit(&buf, " <backingStore>\n");
+ virBufferVSprintf(&buf, "
<path>%s</path>\n",snapshotStrVolPath);
+ if (snapshotStrFormat)
+ virBufferVSprintf(&buf, " <format
type='%s'/>\n",snapshotStrFormat);
+ virBufferAddLit(&buf, " </backingStore>\n");
+
+ // Cleanup snapshot allocations
+ VIR_FREE(snapshotStrVolPath);
+ virStorageVolFree(snapVol);
+ }
+
+ virBufferAddLit(&buf, "</volume>\n");
if (virBufferError(&buf)) {
vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
diff --git a/tools/virsh.pod b/tools/virsh.pod
index cab931c..b1a8544 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -782,7 +782,8 @@ source volume is in.
I<vol-name-or-key> is the name or UUID of the source volume.
=item B<vol-create-as> I<pool-or-uuid> I<name> I<capacity> optional
-I<--allocation> I<size> I<--format> I<string>
+I<--allocation> I<size> I<--format> I<string> I<--snapshot-source-vol>
I<vol-name-or-key>
+I<--snapshot-source-format> I<string>
Create a volume from a set of arguments.
I<pool-or-uuid> is the name or UUID of the storage pool to create the
volume
@@ -794,6 +795,10 @@ I<--allocation> I<size> is the initial size to be
allocated in the volume, with
optional k, M, G, or T suffix.
I<--format> I<string> is used in file based storage pools to specify
the volume
file format to use; raw, bochs, qcow, qcow2, vmdk.
+I<--snapshot-source-vol> I<vol-name-or-key> is the source backing
volume to be used if
+taking a snapshot of an existing volume.
+I<--snapshot-source-format> I<string> is the format of the snapshot
backing volume;
+raw, bochs, qcow, qcow2, vmdk.
=item B<vol-clone> [optional I<--pool> I<pool-or-uuid>]
I<vol-name-or-key> I<name>
-- 1.7.0.1
14 years, 5 months