From f2e5c4201135d13903606cf788df9ba541519ea0 Mon Sep 17 00:00:00 2001 From: afazekas Date: Sun, 18 Oct 2015 09:16:24 +0200 Subject: [PATCH 1/2] create-config-drive: stricter config_image argument handling * config_image is required argument * Exactly one positional argument must be passed * config_image argument can contain white spaces --- create-config-drive | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/create-config-drive b/create-config-drive index ec0f33c..729e288 100755 --- a/create-config-drive +++ b/create-config-drive @@ -48,6 +48,18 @@ done config_image=$1 shift +if [ -z "$config_image" ]; then + echo "The imagename argument must be specified!" >&2 + usage >&2 + exit 3 +fi + +if [ $# -ne 0 ]; then + echo "This command requires exactly one positional argument!" >&2 + usage >&2 + exit 4 +fi + if [ "$ssh_key" ] && [ -f "$ssh_key" ]; then echo "adding pubkey from $ssh_key" ssh_key_data=$(cat "$ssh_key") @@ -83,9 +95,9 @@ if [ "$ssh_key_data" ]; then fi echo "generating configuration image at $config_image" -if ! mkisofs -o $config_image -V cidata -r -J --quiet $config_dir; then +if ! mkisofs -o "$config_image" -V cidata -r -J --quiet $config_dir; then echo "ERROR: failed to create $config_image" >&2 exit 1 fi -chmod a+r $config_image +chmod a+r "$config_image" From d655837da8f3c494c4460735e0698816cc52d404 Mon Sep 17 00:00:00 2001 From: Ivan Zakharyaschev Date: Wed, 25 Jan 2017 05:34:23 +0300 Subject: [PATCH 2/2] virt-query: not every disk has a source https://github.com/larsks/virt-utils/issues/7 For example, a cdrom may not have a source path. virt-delete won't break if the 3rd field is empty; it'll skip it. --- virt-query | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/virt-query b/virt-query index ed429ea..9bec01c 100755 --- a/virt-query +++ b/virt-query @@ -37,8 +37,11 @@ class Domain (object): for disk in self.domxml.xpath('/domain/devices/disk'): if disk.get('type') == 'file': info = {'type': 'file', - 'source': disk.find('source').get('file'), 'target': disk.find('target').get('dev')} + + if disk.find('source') is not None: + info['source'] = disk.find('source').get('file') + yield info def interfaces(self): @@ -70,6 +73,10 @@ def main(): if args.what in ['disk', 'disks']: for disk in dom.disks(): + if not 'source' in disk: + disk['source'] = '' + # This won't break scripts iterating the sources like this: + # for disk_path in $(virt-query "$DOMAIN" disks | awk '{print $3}'); do print '{type} {target} {source}'.format(**disk) elif args.what in ['net', 'interfaces', 'iface']: for iface in dom.interfaces():