All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Fehlig <jfehlig@suse.com>
To: Joao Martins <joao.m.martins@oracle.com>, libvir-list@redhat.com
Cc: Jiri Denemark <jdenemar@redhat.com>, xen-devel@lists.xen.org
Subject: Re: [PATCH v2] libxl: free ifname on libxlDomainMigrationPrepareDef
Date: Sun, 06 Dec 2015 10:04:18 -0700	[thread overview]
Message-ID: <56646A92.7040102__35521.4159856134$1449421573$gmane$org@suse.com> (raw)
In-Reply-To: <1449258301-7335-1-git-send-email-joao.m.martins@oracle.com>

On 12/04/2015 12:45 PM, Joao Martins wrote:
> Commit d2e5538b1 changes virDomainDef to include ifnames
> that autogenerated by libxl, and that are also cleared
> on domain cleanup. One place that's missing is on
> migration, when domain xml is sent to dst libvirtd and
> would contain ifnames from the source libvirtd. This
> would lead to erronous behaviour (as seen in osstest CI)
> such as failing to migrate when a vif with the same name
> existed (belonging to another domain) on destination.

Your patch is certainly one way to fix this issue, but I wonder if we should be
adding the generated ifname to the XML that is sent to the destination.
virDomainNetDefFormat() has this interesting piece of logic

    if (def->ifname &&
        !((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
          (STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX)))) {
        /* Skip auto-generated target names for inactive config. */
        virBufferEscapeString(buf, "<target dev='%s'/>\n", def->ifname);
    }

In the Begin phase, we format the XML that will be sent to the destination based
on current vm->def of the machine running on the source. Calling
virDomainDefFormat() with VIR_DOMAIN_DEF_FORMAT_INACTIVE doesn't seem right. I
tried to see how this is handled in the qemu driver, but couldn't quite figure
it out. Jirka is one of the experts of the qemu migration code, adding him to cc
to see if he has any insights.

I'd like to get this resolved and a fix pushed before 1.3.0 is released since it
causes a migration regression.

Regards,
Jim

>
> This patch adds a helper libxlDomainFreeIfaceNames for
> clearing ifnames on both migration prepare phase and domain
> cleanup. It is done on prepare phase so that we don't affect
> source domain (specially in cases when the migration fails),
> while still allowing interface stats to be consulted during
> the migration.
>
> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
> ---
> Changes since v1:
>  - Commit message is changed
>  - Clear ifnames on prepare phase as opposed to begin phase.
> ---
>  src/libxl/libxl_domain.c    | 32 ++++++++++++++++++++++----------
>  src/libxl/libxl_domain.h    |  3 +++
>  src/libxl/libxl_migration.c |  2 ++
>  3 files changed, 27 insertions(+), 10 deletions(-)
>
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index ef92974..487589d 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -728,16 +728,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
>          }
>      }
>  
> -    if ((vm->def->nnets)) {
> -        size_t i;
> -
> -        for (i = 0; i < vm->def->nnets; i++) {
> -            virDomainNetDefPtr net = vm->def->nets[i];
> -
> -            if (STRPREFIX(net->ifname, "vif"))
> -                VIR_FREE(net->ifname);
> -        }
> -    }
> +    libxlDomainFreeIfaceNames(vm->def);
>  
>      if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) > 0) {
>          if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
> @@ -923,6 +914,27 @@ libxlDomainCreateIfaceNames(virDomainDefPtr def, libxl_domain_config *d_config)
>      }
>  }
>  
> +/*
> + * Removes autogenerated interface names for the network devices in
> + * parameter def. User-provided interface names are skipped.
> + */
> +void
> +libxlDomainFreeIfaceNames(virDomainDefPtr def)
> +{
> +    size_t i;
> +
> +    for (i = 0; i < def->nnets; i++) {
> +        virDomainNetDefPtr net = def->nets[i];
> +
> +        if (!net->ifname)
> +            continue;
> +
> +        if (STRPREFIX(net->ifname, "vif"))
> +            VIR_FREE(net->ifname);
> +    }
> +}
> +
> +
>  
>  /*
>   * Start a domain through libxenlight.
> diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
> index 44b3e0b..70c139c 100644
> --- a/src/libxl/libxl_domain.h
> +++ b/src/libxl/libxl_domain.h
> @@ -135,6 +135,9 @@ int
>  libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver,
>                               virDomainObjPtr vm);
>  
> +void
> +libxlDomainFreeIfaceNames(virDomainDefPtr def);
> +
>  int
>  libxlDomainStart(libxlDriverPrivatePtr driver,
>                   virDomainObjPtr vm,
> diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
> index 0d23e5f..1ca31ab 100644
> --- a/src/libxl/libxl_migration.c
> +++ b/src/libxl/libxl_migration.c
> @@ -288,6 +288,8 @@ libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver,
>                                          VIR_DOMAIN_DEF_PARSE_INACTIVE)))
>          goto cleanup;
>  
> +    libxlDomainFreeIfaceNames(def);
> +
>      if (dname) {
>          name = def->name;
>          if (VIR_STRDUP(def->name, dname) < 0) {

       reply	other threads:[~2015-12-06 17:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1449258301-7335-1-git-send-email-joao.m.martins@oracle.com>
2015-12-06 17:04 ` Jim Fehlig [this message]
     [not found] ` <56646A92.7040102@suse.com>
2015-12-06 17:59   ` [libvirt] [PATCH v2] libxl: free ifname on libxlDomainMigrationPrepareDef Jim Fehlig
     [not found]   ` <56647796.7060000@suse.com>
2015-12-06 18:11     ` Jim Fehlig
     [not found]     ` <56647A61.4020808@suse.com>
2015-12-06 23:27       ` Joao Martins
2015-12-04 19:45 Joao Martins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='56646A92.7040102__35521.4159856134$1449421573$gmane$org@suse.com' \
    --to=jfehlig@suse.com \
    --cc=jdenemar@redhat.com \
    --cc=joao.m.martins@oracle.com \
    --cc=libvir-list@redhat.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.