[libvirt] [PATCH 1/5] Add https protocol support for cdrom disk

From: Aline Manera <alinefm@br.ibm.com> The https protocol is also accepted by qemu/KVM when specifying the cdrom ISO image. The xml should be as following: <disk type='network' device='cdrom'> <source protocol='https' name='/url/path'> <host name='host.name' port='443'/> </source> </disk> Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- docs/formatdomain.html.in | 8 +++++ docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 6 ++++ .../qemuxml2argv-disk-cdrom-network-https.args | 8 +++++ .../qemuxml2argv-disk-cdrom-network-https.xml | 37 ++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 8 files changed, 64 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f5a36d9..240571f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1511,6 +1511,14 @@ </disk> <disk type='network' device='cdrom'> <driver name='qemu' type='raw'/> + <source protocol="https" name="url_path"> + <host name="hostname" port="443"/> + </source> + <target dev='hdc' bus='ide' tray='open'/> + <readonly/> + </disk> + <disk type='network' device='cdrom'> + <driver name='qemu' type='raw'/> <source protocol="ftp" name="url_path"> <host name="hostname" port="21"/> </source> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ecd3a42..2f91f0f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1231,6 +1231,7 @@ <value>gluster</value> <value>iscsi</value> <value>http</value> + <value>https</value> <value>ftp</value> </choice> </attribute> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e5fe900..04563f6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -265,6 +265,7 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST, "gluster", "iscsi", "http", + "https", "ftp") VIR_ENUM_IMPL(virDomainDiskProtocolTransport, VIR_DOMAIN_DISK_PROTO_TRANS_LAST, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e4dfee9..d54b29e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -543,6 +543,7 @@ enum virDomainDiskProtocol { VIR_DOMAIN_DISK_PROTOCOL_GLUSTER, VIR_DOMAIN_DISK_PROTOCOL_ISCSI, VIR_DOMAIN_DISK_PROTOCOL_HTTP, + VIR_DOMAIN_DISK_PROTOCOL_HTTPS, VIR_DOMAIN_DISK_PROTOCOL_FTP, VIR_DOMAIN_DISK_PROTOCOL_LAST diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1521431..883b513 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3905,6 +3905,12 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED, disk->hosts->port ? disk->hosts->port : "80"); virBufferEscape(&opt, ',', ",", "%s,", disk->src); break; + case VIR_DOMAIN_DISK_PROTOCOL_HTTPS: + virBufferAsprintf(&opt, "file=https://%s:%s", + disk->hosts->name, + disk->hosts->port ? disk->hosts->port : "443"); + virBufferEscape(&opt, ',', ",", "%s,", disk->src); + break; case VIR_DOMAIN_DISK_PROTOCOL_FTP: virBufferAsprintf(&opt, "file=ftp://%s:%s", disk->hosts->name, diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args new file mode 100644 index 0000000..affa794 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args @@ -0,0 +1,8 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/kvm -S \ +-M pc-1.2 -m 1024 -smp 1 -nographic -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -boot d -usb \ +-drive \ +file=https://host.name:443/url/path/file.iso,if=none,media=cdrom,id=drive-ide0-1-... \ +-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml new file mode 100644 index 0000000..b8a60ed --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml @@ -0,0 +1,37 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-1.2'>hvm</type> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/bin/kvm</emulator> + <disk type='network' device='cdrom'> + <driver name='qemu' type='raw'/> + <source protocol='https' name='/url/path/file.iso'> + <host name='host.name' port='443'/> + </source> + <target dev='hdc' bus='ide'/> + <readonly/> + <alias name='ide0-1-0'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fdf1d31..a11c9a8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -445,6 +445,8 @@ mymain(void) DO_TEST("disk-cdrom", NONE); DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE); + DO_TEST("disk-cdrom-network-https", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, + QEMU_CAPS_DRIVE); DO_TEST("disk-cdrom-network-ftp", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE); DO_TEST("disk-cdrom-empty", QEMU_CAPS_DRIVE); -- 1.7.9.5

Please ignore the patchs [1-3]. I followed the contributer guidelines, before I push the patches I did a "git pull --rebase" operation, Then the newest three patches are included into my patches. Are there anything I missed? On 2013-09-17 22:50 , hzguanqiang wrote: From: Aline Manera <alinefm@br.ibm.com> The https protocol is also accepted by qemu/KVM when specifying the cdrom ISO image. The xml should be as following: <disk type='network' device='cdrom'> <source protocol='https' name='/url/path'> <host name='host.name' port='443'/> </source> </disk> Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- docs/formatdomain.html.in | 8 +++++ docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 6 ++++ .../qemuxml2argv-disk-cdrom-network-https.args | 8 +++++ .../qemuxml2argv-disk-cdrom-network-https.xml | 37 ++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 8 files changed, 64 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f5a36d9..240571f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1511,6 +1511,14 @@ </disk> <disk type='network' device='cdrom'> <driver name='qemu' type='raw'/> + <source protocol="https" name="url_path"> + <host name="hostname" port="443"/> + </source> + <target dev='hdc' bus='ide' tray='open'/> + <readonly/> + </disk> + <disk type='network' device='cdrom'> + <driver name='qemu' type='raw'/> <source protocol="ftp" name="url_path"> <host name="hostname" port="21"/> </source> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ecd3a42..2f91f0f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1231,6 +1231,7 @@ <value>gluster</value> <value>iscsi</value> <value>http</value> + <value>https</value> <value>ftp</value> </choice> </attribute> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e5fe900..04563f6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -265,6 +265,7 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST, "gluster", "iscsi", "http", + "https", "ftp") VIR_ENUM_IMPL(virDomainDiskProtocolTransport, VIR_DOMAIN_DISK_PROTO_TRANS_LAST, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e4dfee9..d54b29e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -543,6 +543,7 @@ enum virDomainDiskProtocol { VIR_DOMAIN_DISK_PROTOCOL_GLUSTER, VIR_DOMAIN_DISK_PROTOCOL_ISCSI, VIR_DOMAIN_DISK_PROTOCOL_HTTP, + VIR_DOMAIN_DISK_PROTOCOL_HTTPS, VIR_DOMAIN_DISK_PROTOCOL_FTP, VIR_DOMAIN_DISK_PROTOCOL_LAST diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1521431..883b513 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3905,6 +3905,12 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED, disk->hosts->port ? disk->hosts->port : "80"); virBufferEscape(&opt, ',', ",", "%s,", disk->src); break; + case VIR_DOMAIN_DISK_PROTOCOL_HTTPS: + virBufferAsprintf(&opt, "file=https://%s:%s", + disk->hosts->name, + disk->hosts->port ? disk->hosts->port : "443"); + virBufferEscape(&opt, ',', ",", "%s,", disk->src); + break; case VIR_DOMAIN_DISK_PROTOCOL_FTP: virBufferAsprintf(&opt, "file=ftp://%s:%s", disk->hosts->name, diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args new file mode 100644 index 0000000..affa794 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args @@ -0,0 +1,8 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/kvm -S \ +-M pc-1.2 -m 1024 -smp 1 -nographic -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -boot d -usb \ +-drive \ +file=https://host.name:443/url/path/file.iso,if=none,media=cdrom,id=drive-ide0-1-... \ +-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml new file mode 100644 index 0000000..b8a60ed --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.xml @@ -0,0 +1,37 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>1048576</memory> + <currentMemory unit='KiB'>1048576</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc-1.2'>hvm</type> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/bin/kvm</emulator> + <disk type='network' device='cdrom'> + <driver name='qemu' type='raw'/> + <source protocol='https' name='/url/path/file.iso'> + <host name='host.name' port='443'/> + </source> + <target dev='hdc' bus='ide'/> + <readonly/> + <alias name='ide0-1-0'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fdf1d31..a11c9a8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -445,6 +445,8 @@ mymain(void) DO_TEST("disk-cdrom", NONE); DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE); + DO_TEST("disk-cdrom-network-https", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, + QEMU_CAPS_DRIVE); DO_TEST("disk-cdrom-network-ftp", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE); DO_TEST("disk-cdrom-empty", QEMU_CAPS_DRIVE); -- 1.7.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ------------------ Best regards! GuanQiang 22:52:52

On 09/17/2013 08:57 AM, hzguanqiang@corp.netease.com wrote:
Please ignore the patchs [1-3]. I followed the contributer guidelines, before I push the patches I did a "git pull --rebase" operation, Then the newest three patches are included into my patches. Are there anything I missed?
That generally means you applied some patches locally without creating a new branch. If you want to discard non-upstream patches that are unrelated to what you are working on, you can do 'git rebase -i' (if your git version is too old, you might have to spell it 'git rebase -i origin'), and delete the lines for the patches you are no longer interested in. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Well, Eric, I've created a workbranch, maybe I need to do the rebase operation. I thought that's just ok to follow the steps where http://libvirt.org/hacking.html says: git checkout master git pull git checkout -t origin -b workbranch ...modify on workbranch... git pull --rebase ./autogen.sh ./configure --enable-werror make check make syntax-check make -C tests valgrind git pull --rebase git send-email ... Maybe I need to do a "git rebase -i orgin" before send-email, Right? So What should I do now? Modify the commit message and send again? Thanks. On 2013-09-17 23:04 , Eric Blake wrote: On 09/17/2013 08:57 AM, hzguanqiang@corp.netease.com wrote:
Please ignore the patchs [1-3]. I followed the contributer guidelines, before I push the patches I did a "git pull --rebase" operation, Then the newest three patches are included into my patches. Are there anything I missed?
That generally means you applied some patches locally without creating a new branch. If you want to discard non-upstream patches that are unrelated to what you are working on, you can do 'git rebase -i' (if your git version is too old, you might have to spell it 'git rebase -i origin'), and delete the lines for the patches you are no longer interested in. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------------------ Best regards! GuanQiang 23:06:36

On Tue, Sep 17, 2013 at 11:15:55PM +0800, hzguanqiang@corp.netease.com wrote:
Well, Eric, I've created a workbranch, maybe I need to do the rebase operation. I thought that's just ok to follow the steps where http://libvirt.org/hacking.html says: git checkout master git pull git checkout -t origin -b workbranch ...modify on workbranch... git pull --rebase ./autogen.sh ./configure --enable-werror make check make syntax-check make -C tests valgrind git pull --rebase git send-email ...
I think your 'git pull --rebase' bit is wrong. There is also no need for 'configure --enable-werror' - autogen.sh runs 'configure' for you, and --enable-werror is turned on by default if building from GIT. Here is what I normally use To start a new piece of work git checkout master git pull git checkout -b workbranch ...modify on workbranch... Once the work is ready, rebase to latest git git checkout master git pull git checkout workbranch git rebase master Test the rebase ./autogen.sh --system make check make syntax-check make -C tests valgrind Send patches git send-email ...other.args... master... Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Ok, I got it. Thanks for Daniel and Eric's help. On 2013-09-17 23:22 , Daniel P. Berrange wrote: On Tue, Sep 17, 2013 at 11:15:55PM +0800, hzguanqiang@corp.netease.com wrote:
Well, Eric, I've created a workbranch, maybe I need to do the rebase operation. I thought that's just ok to follow the steps where http://libvirt.org/hacking.html says: git checkout master git pull git checkout -t origin -b workbranch ...modify on workbranch... git pull --rebase ./autogen.sh ./configure --enable-werror make check make syntax-check make -C tests valgrind git pull --rebase git send-email ...
I think your 'git pull --rebase' bit is wrong. There is also no need for 'configure --enable-werror' - autogen.sh runs 'configure' for you, and --enable-werror is turned on by default if building from GIT. Here is what I normally use To start a new piece of work git checkout master git pull git checkout -b workbranch ...modify on workbranch... Once the work is ready, rebase to latest git git checkout master git pull git checkout workbranch git rebase master Test the rebase ./autogen.sh --system make check make syntax-check make -C tests valgrind Send patches git send-email ...other.args... master... Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| ------------------ Best regards! GuanQiang 23:48:32
participants (4)
-
Daniel P. Berrange
-
Eric Blake
-
hzguanqiang@corp.netease.com
-
hzguanqiang@gmail.com