[libvirt] [PATCH] Check disk target collision when parsing domain xml

The current domain xml parsing doesn't check if disks are specified with duplicate targets ("hda" etc.). The attached patch adds a check for this. Thanks, Cole commit 27df1653474738a2ce83c89e7bdb2c4f7327f9b6 Author: Cole Robinson <crobinso@dhcp-100-19-219.bos.redhat.com> Date: Thu Aug 21 14:58:04 2008 -0400 Check for duplicate disk targets when parsing domain xml. diff --git a/src/domain_conf.c b/src/domain_conf.c index 6b23474..ed6cc8b 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -1955,6 +1955,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } else { virDomainDiskDefPtr ptr = def->disks; while (ptr) { + if (ptr->next && STREQ(disk->dst, ptr->next->dst)) { + virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("duplicate disk target '%s'"), + disk->dst); + goto error; + } if (!ptr->next || virDomainDiskCompare(disk, ptr->next) < 0) { disk->next = ptr->next; ptr->next = disk;

On Thu, Aug 21, 2008 at 11:20:13PM -0400, Cole Robinson wrote:
The current domain xml parsing doesn't check if disks are specified with duplicate targets ("hda" etc.). The attached patch adds a check for this.
+1. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my OCaml programming blog: http://camltastic.blogspot.com/ Fedora now supports 60 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora

On Thu, Aug 21, 2008 at 11:20:13PM -0400, Cole Robinson wrote:
The current domain xml parsing doesn't check if disks are specified with duplicate targets ("hda" etc.). The attached patch adds a check for this.
Thanks, Cole
commit 27df1653474738a2ce83c89e7bdb2c4f7327f9b6 Author: Cole Robinson <crobinso@dhcp-100-19-219.bos.redhat.com> Date: Thu Aug 21 14:58:04 2008 -0400
Check for duplicate disk targets when parsing domain xml.
diff --git a/src/domain_conf.c b/src/domain_conf.c index 6b23474..ed6cc8b 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -1955,6 +1955,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } else { virDomainDiskDefPtr ptr = def->disks; while (ptr) { + if (ptr->next && STREQ(disk->dst, ptr->next->dst)) {
I'm confused as to why you're comparing for dups against ptr->next->dst instead of ptr->dst. It would seem to miss a duplication disk target check for the very first device..
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, + _("duplicate disk target '%s'"), + disk->dst); + goto error; + } if (!ptr->next || virDomainDiskCompare(disk, ptr->next) < 0) { disk->next = ptr->next; ptr->next = disk;
Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Thu, Aug 21, 2008 at 11:20:13PM -0400, Cole Robinson wrote:
The current domain xml parsing doesn't check if disks are specified with duplicate targets ("hda" etc.). The attached patch adds a check for this.
Thanks, Cole
commit 27df1653474738a2ce83c89e7bdb2c4f7327f9b6 Author: Cole Robinson <crobinso@dhcp-100-19-219.bos.redhat.com> Date: Thu Aug 21 14:58:04 2008 -0400
Check for duplicate disk targets when parsing domain xml.
diff --git a/src/domain_conf.c b/src/domain_conf.c index 6b23474..ed6cc8b 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -1955,6 +1955,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, } else { virDomainDiskDefPtr ptr = def->disks; while (ptr) { + if (ptr->next && STREQ(disk->dst, ptr->next->dst)) {
I'm confused as to why you're comparing for dups against ptr->next->dst instead of ptr->dst. It would seem to miss a duplication disk target check for the very first device..
I was a bit confused myself. This came before I realized the device ordering was a little funky, so I just blindly used ptr->next. This is however fixed to work correctly with my later patch ("Fix disk device ordering"). - Cole
participants (3)
-
Cole Robinson
-
Daniel P. Berrange
-
Richard W.M. Jones