[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, 10 months
[libvirt] [PATCH] Add the vol-* commands to the virsh man page.
by Justin Clift
---
tools/virsh.pod | 95
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 95 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 422ae7f..cab931c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -755,6 +755,101 @@ Returns the UUID of the named I<pool>.
=back
+=head1 VOLUME COMMANDS
+
+=item B<vol-create> I<pool-or-uuid> I<FILE>
+
+Create a volume from an XML <file>.
+I<pool-or-uuid> is the name or UUID of the storage pool to create the
volume in.
+I<FILE> is the XML <file> with the volume definition. An easy way to
create the
+XML <file> is to use the B<vol-dumpxml> command to obtain the
definition of a
+pre-existing volume.
+
+B<Example>
+
+ virsh vol-dumpxml --pool storagepool1 appvolume1 > newvolume.xml
+ edit newvolume.xml
+ virsh vol-create differentstoragepool newvolume.xml
+
+=item B<vol-create-from> I<pool-or-uuid> I<FILE> [optional I<--inputpool>
+I<pool-or-uuid>] I<vol-name-or-key>
+
+Create a volume, using another volume as input.
+I<pool-or-uuid> is the name or UUID of the storage pool to create the
volume in.
+I<FILE> is the XML <file> with the volume definition.
+I<--inputpool> I<pool-or-uuid> is the name or uuid of the storage pool the
+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>
+
+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
+in.
+I<name> is the name of the new volume.
+I<capacity> is the size of the volume to be created, with optional k,
M, G, or
+T suffix.
+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.
+
+=item B<vol-clone> [optional I<--pool> I<pool-or-uuid>]
I<vol-name-or-key> I<name>
+
+Clone an existing volume. Less powerful, but easier to type, version of
+B<vol-create-from>.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool to
create the volume in.
+I<vol-name-or-key> is the name or UUID of the source volume.
+I<name> is the name of the new volume.
+
+=item B<vol-delete> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key>
+
+Delete a given volume.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the
volume is in.
+I<vol-name-or-key> is the name or UUID of the volume to delete.
+
+=item B<vol-wipe> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key>
+
+Wipe a volume, ensure data previously on the volume is not accessible
to future reads.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the
volume is in.
+I<vol-name-or-key> is the name or UUID of the volume to wipe.
+
+=item B<vol-dumpxml> [optional I<--pool> I<pool-or-uuid>]
I<vol-name-or-key>
+
+Output the volume information as an XML dump to stdout.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the
volume is in.
+I<vol-name-or-key> is the name or UUID of the volume to output the XML of.
+
+=item B<vol-info> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key>
+
+Returns basic information about the given storage volume.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the
volume is in.
+I<vol-name-or-key> is the name or UUID of the volume to return
information for.
+
+=item B<vol-list> I<--pool> I<pool-or-uuid>
+
+Return the list of volumes in the given storage pool.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool.
+
+=item B<vol-path> [optional I<--pool> I<pool-or-uuid>] I<vol-name-or-key>
+
+Return the path for a given volume.
+I<--pool> I<pool-or-uuid> is the name or UUID of the storage pool the
volume is in.
+I<vol-name-or-key> is the name or key of the volume to return the path for.
+
+=item B<vol-name> I<vol-key-or-path>
+
+Return the name for a given volume.
+I<vol-key-or-path> is the key or path of the volume to return the name for.
+
+=item B<vol-key> I<vol-uuid>
+
+Return the volume key for a given volume UUID.
+I<vol-uuid> is the UUID of the volume to return the volume key for.
+
+=back
+
=head1 SECRET COMMMANDS
The following commands manipulate "secrets" (e.g. passwords,
passphrases and
--
1.7.0.1
14 years, 10 months
[libvirt] Question about migration requirement
by Bruce Rogers
I've noticed that there seems to be some additional requirements placed on a migration, as compared to just remote management via libvirt.
For example, when I try to do the following:
virsh migrate running_vm_name qemu+ssh://1.2.3.4/system
there seems to be a requirment that both the source and target hosts must resolve 1.2.3.4 the same way as far as naming services is concerned. Without being able to resolve to the same name on both the source and target, the migration will fail.
Note that I can ssh to the other machine just fine using the ip address, or even do the following without problem:
virsh -c qemu+ssh://1.2.3.4/system <some-command>
Is this additional <requirement> for migration intentional (some security issue, etc), or is it just an artifact of implementation, which could be fixed to not be needlessly restrictive.
Bruce
14 years, 10 months
[libvirt] [PATCH] autobuild.sh: avoid bashism
by Eric Blake
* autobuild.sh: Replace 'set -o pipefail' with POSIX alternative.
Reported by Matthias Bolte.
---
On IRC, Matthias pointed out that his testing of my recent
autobuild.sh patch triggered a dash failure. Unfortunately,
the checkbashisms script is not smart enough to realize that
'set -o pipefail' is a bashism, yet it also does not provide
a bug reporting address in checkbashisms --help :(
autobuild.sh | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/autobuild.sh b/autobuild.sh
index 4de5af8..66ba132 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -35,9 +35,15 @@ esac
make
make install
-set -o pipefail
-make check 2>&1 | tee "$RESULTS"
-make syntax-check 2>&1 | tee -a "$RESULTS"
+# set -o pipefail is a bashism; this use of exec is the POSIX alternative
+exec 3>&1
+st=$(
+ exec 4>&1 >&3
+ { make check syntax-check 2>&1; echo $? >&4; } \
+ | tee "$RESULTS"
+)
+exec 3>&-
+test $st = 0
test -x /usr/bin/lcov && make cov
rm -f *.tar.gz
--
1.7.0.1
14 years, 10 months
[libvirt] Break up virsh man page into smaller sections?
by Justin Clift
Hi all,
Looking at the virsh man page (tools/virsh.pod), it's getting pretty
unwieldy and hard to grok for end users.
Wondering if it's worth breaking it up into sections?
Maybe something similar to how git structures their man pages?
ie.
man virsh
Giving an overview, the categories DEVICE, DOMAIN, NETWORKING,
STORAGE, (etc), and listing the more detailed man pages)
man virsh-console
(initially a copy of the existing virsh console man page contents.)
virsh console domain-id
Connect the virtual serial console for the guest.
man virsh-create
(initially a copy of the existing virsh create man page contents.)
virsh create FILE
Create a domain from an XML <file>. An easy way to create the XML
<file> is to use the dumpxml command to obtain the definition of
a pre-existing guest.
Example
# virsh dumpxml <domain-id> > domain.xml edit domain.xml virsh \
create < domain.xml
<etc>
???
Regards and best wishes,
Justin Clift
--
Salasaga - Open Source eLearning IDE
http://www.salasaga.org
14 years, 10 months
[libvirt] [PATCHv3 0/2] build: automate VPATH testing
by Eric Blake
Picking up on a patch series that I had started a while ago:
https://www.redhat.com/archives/libvir-list/2010-April/msg01259.html
I finally have all the pieces in place for a successful run of
./autobuild.sh with a VPATH build. Now, we just have to remember
to run ./autobuild.sh more frequently.
Eric Blake (2):
build: fix VPATH build of docs
autobuild.sh: use VPATH build
.gitignore | 1 +
autobuild.sh | 10 +++++-----
docs/Makefile.am | 46 +++++++++++++++++++++++++++-------------------
docs/apibuild.py | 18 +++++++++++++-----
4 files changed, 46 insertions(+), 29 deletions(-)
14 years, 10 months
[libvirt] [PATCH 0/1] Fix nodeDeviceDestroy return value
by David Allan
Set nodeDeviceDestroy's return value correctly in failure cases and clarify the error message generated when the parent device is not vport capable.
David Allan (1):
Fix device destroy return value
src/conf/node_device_conf.c | 4 ++--
src/node_device/node_device_driver.c | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
14 years, 10 months
[libvirt] [PATCH 0/1] Update nodedev scsi_host data
by David Allan
While investigating https://bugzilla.redhat.com/show_bug.cgi?id=597998 I noticed that my nodedev-create operations were timing out more often than not. This patch works around a race between udev generating a new device event and the corresponding sysfs entries being populated. This behavior has appeared before, but previously it was limited to incorrect WWNs; now no FC capability appears at all until the nodedev entry is refreshed.
David Allan (1):
Update nodedev scsi_host data before use
src/node_device/node_device_driver.c | 19 +++----------------
1 files changed, 3 insertions(+), 16 deletions(-)
14 years, 10 months