[libvirt] [PATCH 2/2] conf: Reuse virDomainDefCheckDuplicateDiskWWN to check disk serial too
Peter Krempa
pkrempa at redhat.com
Tue Sep 29 16:59:40 UTC 2015
On Tue, Sep 29, 2015 at 18:50:48 +0200, Jiri Denemark wrote:
> On Tue, Sep 29, 2015 at 18:38:05 +0200, Peter Krempa wrote:
> > Rename the function to virDomainDefCheckDuplicateDiskInfo and make it
> > check disk serials too.
> >
> > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1245013
> > ---
> > src/conf/domain_conf.c | 15 ++++++++++++++-
> > src/conf/domain_conf.h | 2 +-
> > src/libvirt_private.syms | 2 +-
> > src/qemu/qemu_process.c | 2 +-
> > 4 files changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index 393ece7..e9d61db 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -24451,7 +24451,7 @@ virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
> >
> >
> > int
> > -virDomainDefCheckDuplicateDiskWWN(virDomainDefPtr def)
> > +virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def)
> > {
> > size_t i;
> > size_t j;
> > @@ -24469,6 +24469,19 @@ virDomainDefCheckDuplicateDiskWWN(virDomainDefPtr def)
> > }
> > }
> > }
> > +
> > + if (def->disks[i]->serial) {
> > + for (j = i + 1; j < def->ndisks; j++) {
> > + if (STREQ_NULLABLE(def->disks[i]->serial,
> > + def->disks[j]->serial)) {
> > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> > + _("Disks '%s' and '%s' have identical serial"),
> > + def->disks[i]->dst,
> > + def->disks[j]->dst);
> > + return -1;
> > + }
> > + }
> > + }
>
> Any reason for going through all disks twice? Wouldn't it be better to
> go through them once and check for both serial and wwn within a single
> loop? :-)
Erm. I'm going to blame me writing suboptimal (read: crappy) code on
hunger.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150929/a28cc540/attachment-0001.sig>
More information about the libvir-list
mailing list