1. 17 3月, 2018 1 次提交
    • J
      libxl: MigrateBegin: Dont call EndAPI in helper function · 64370c4b
      Jim Fehlig 提交于
      The libxlDomainMigrateBegin3Params API locks and ref counts the associated
      virDomainObj but relies on the helper function libxlDomainMigrationBegin
      to unref/unlock the object. libxlDomainMigrationBegin is also used by
      libxlDomainMigratePerform3Params for p2p migration, but in that case the
      lock/ref and unref/unlock are properly handled in the API entry point. So
      p2p migrations suffer a double unref/unlock in the Perform API.
      
      Remove the unref/unlock (virDomainObjEndAPI) from libxlDomainMigrationBegin
      and adjust libxlDomainMigrateBegin3Params to properly unref/unlock
      the virDomainObj on success and error paths.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      64370c4b
  2. 22 2月, 2018 1 次提交
  3. 26 1月, 2018 1 次提交
    • J
      libxl: resume lock process after failed migration · 0c710a37
      Jim Fehlig 提交于
      During migration, the lock process is paused in the perform phase
      but not resumed if there is a subsequent failure, leaving the locked
      resource unprotected.
      
      The perform phase itself can fail, in which case the lock process
      should be resumed before returning from perform. The finish phase
      could also fail on the destination host, in which case the migration
      is canceled in the confirm phase and the VM is resumed. The lock
      process needs to be resumed there as well.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      0c710a37
  4. 03 4月, 2017 1 次提交
    • M
      virGetDomain: Set domain ID too · 5683b213
      Michal Privoznik 提交于
      So far our code is full of the following pattern:
      
        dom = virGetDomain(conn, name, uuid)
        if (dom)
            dom->id = 42;
      
      There is no reasong why it couldn't be just:
      
        dom = virGetDomain(conn, name, uuid, id);
      
      After all, client domain representation consists of tuple (name,
      uuid, id).
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      5683b213
  5. 27 3月, 2017 1 次提交
  6. 16 3月, 2017 1 次提交
  7. 17 2月, 2017 1 次提交
  8. 16 2月, 2017 2 次提交
    • B
      libxl: add tunnelled migration support · 6a95edf9
      Bob Liu 提交于
      Tunnelled migration doesn't require any extra network connections
      beside the libvirt daemon.  It's capable of strong encryption and the
      default option of openstack-nova.
      
      This patch adds the tunnelled migration(Tunnel3params) support to
      libxl.  On the source side, the data flow is:
      
       * libxlDoMigrateSend() -> pipe libxlTunnel3MigrationFunc() polls pipe
       * out and then write to dest stream.
      
      While on the destination side:
       * Stream -> pipe -> 'recvfd of libxlDomainStartRestore'
      
      The usage is the same as p2p migration, execpt adding one extra
      '--tunnelled' to the libvirt p2p migration command.
      Signed-off-by: NBob Liu <bob.liu@oracle.com>
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      6a95edf9
    • J
      libxl: refactor libxlDomainMigrationPrepare · d2100f2b
      Joao Martins 提交于
      The newly introduced function libxlDomainMigrationPrepareAny
      will be shared between P2P and tunnelled variations.
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      d2100f2b
  9. 25 10月, 2016 1 次提交
    • J
      libxl: fix leaking of allocated migration ports · f830674b
      Jim Fehlig 提交于
      Although the migration port is immediately released in the
      finish phase of migration, it was never set in the domain
      private object when allocated in the prepare phase. So
      libxlDomainMigrationFinish() always released a 0-initialized
      migrationPort, leaking any allocated port. After enough
      migrations to exhaust the migration port pool, migration would
      fail with
      
      error: internal error: Unable to find an unused port in range
             'migration' (49152-49216)
      
      Fix it by setting libxlDomainObjPrivate->migrationPort to the
      port allocated in the prepare phase. While at it, also fix
      leaking an allocated port if the prepare phase fails.
      f830674b
  10. 26 9月, 2016 1 次提交
  11. 22 9月, 2016 1 次提交
    • J
      libxl: support VIR_MIGRATE_PERSIST_DEST migration flag · 1fc90ae9
      Jim Fehlig 提交于
      By default, virt-manager (and likely other libvirt-based apps) sets
      the VIR_MIGRATE_PERSIST_DEST flag when invoking the migrate API, which
      fails in a Xen setup since the libxl driver does not support the flag.
      
      Persisting a domain is a trivial task in the grand scheme of migration,
      so be nice to libvirt apps and add support for VIR_MIGRATE_PERSIST_DEST
      in the libxl driver.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      1fc90ae9
  12. 04 8月, 2016 1 次提交
  13. 02 8月, 2016 1 次提交
  14. 13 6月, 2016 1 次提交
    • W
      libxl: fix vm lock overwritten bug · 9ac94507
      Wang Yufei 提交于
      In libxl driver we do virObjectRef in libxlDomainObjBeginJob,
      If virCondWaitUntil failed, it goes to error, do virObjectUnref,
      There's a chance that someone undefine the vm at the same time,
      and refs unref to zero, vm is freed in libxlDomainObjBeginJob.
      But the vm outside function is not Null, we do virObjectUnlock(vm).
      That's how we overwrite the vm memory after it's freed. I fix it.
      Signed-off-by: NWang Yufei <james.wangyufei@huawei.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      9ac94507
  15. 07 6月, 2016 1 次提交
    • P
      conf: Add infrastructure for adding configuration validation · b394af16
      Peter Krempa 提交于
      Until now we weren't able to add checks that would reject configuration
      once accepted by the parser. This patch adds a new callback and
      infrastructure to add such checks. In this patch all the places where
      rejecting a now-invalid configuration wouldn't be a good idea are marked
      with a new parser flag.
      b394af16
  16. 17 5月, 2016 1 次提交
    • J
      libxl: Free migration cookie · 1222a303
      John Ferlan 提交于
      Commit id 'f9edcfa4' added cookie manipulation for libxl; however, some
      cookie crumb cleanup was missed. Found by Coverity.
      
      In libxlDomainMigrationBegin, the cookie is allocated and baked; however,
      the mig ingredients weren't cleaned up.
      
      In libxlDomainMigrationPrepare, when the 'mig' cookie is added to the
      args, set the 'mig = NULL'; otherwise, other failure paths between when
      the code ate the cookie data and when it was added to args would fail
      to clean up the crumbs.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      1222a303
  17. 11 5月, 2016 2 次提交
    • J
      libxl: support migration stream V2 in migration · f9edcfa4
      Jim Fehlig 提交于
      Similar to "support Xen migration stream V2 in save/restore",
      add support for indicating the migration stream version in
      the migration code. To accomplish this, add a minimal migration
      cookie in the libxl driver that is passed between source and
      destination hosts. Initially, the cookie is only used in
      the Begin and Prepare phases of migration to communicate the
      version of the migration stream produced by the source.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      f9edcfa4
    • J
      libxl: support Xen migration stream V2 in save/restore · 5325123d
      Jim Fehlig 提交于
      Xen 4.6 introduced a new migration stream commonly referred to as
      "migration V2". Xen 4.6 and newer always produce this new stream,
      whereas Xen 4.5 and older always produce the legacy stream.
      Support for migration stream V2 can be detected at build time with
      LIBXL_HAVE_SRM_V2 from libxl.h. The legacy and V2 streams are not
      compatible, but a V2 host can accept and convert a legacy stream.
      
      Commit e7440656 changed the libxl driver to use the lowest libxl
      API version possible (version 0x040200) to ensure the driver
      builds against older Xen releases. The old 4.2 restore API does
      not support specifying a stream version and assumes a legacy
      stream, even if the incoming stream is migration V2. Thinking it
      has been given a legacy stream, libxl will fail to convert an
      incoming stream that is already V2, which causes the entire
      restore operation to fail. Xen's libvirt-related OSSTest has been
      failing since commit e7440656 landed in libvirt.git master. One
      of the more recent failures can be seen here
      
      http://lists.xenproject.org/archives/html/xen-devel/2016-05/msg00071.html
      
      This patch changes the call to libxl_domain_create_restore() to
      include the stream version if LIBXL_HAVE_SRM_V2 is defined. The
      version field of the libxlSavefileHeader struct is also updated
      to '2' when LIBXL_HAVE_SRM_V2 is defined, ensuring the stream
      version in the header matches the actual stream version produced
      by Xen. Along with bumping the libxl API requirement to 0x040400,
      this patch fixes save/restore on a migration V2 Xen host.
      
      Oddly, migration has never used the libxlSavefileHeader. It
      handles passing configuration in the Begin and Prepare phases,
      and then calls libxl directly to transfer domain state/memory
      in the Perform phase. A subsequent patch will add stream
      version handling in the Begin and Prepare phase handshaking,
      which will fix the migration related OSSTest failures.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      5325123d
  18. 10 2月, 2016 2 次提交
    • J
      libxl: keepalive messages support · 5194eb95
      Joao Martins 提交于
      This patch introduces keep alive messages support for P2P migration
      and it adds two new configuration entries namely 'keepalive_interval'
      'keepalive_count' to control it. Behavior of these entries is the
      same as qemu driver thus the description is copied from there
      with just a few simplifications.
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      5194eb95
    • J
      libxl: add p2p migration · a79da245
      Joao Martins 提交于
      Introduce support for VIR_MIGRATE_PEER2PEER in libvirt migration.
      Most of the changes occur at the source and no modifications at
      the receiver.
      
      In P2P mode there is only the Perform phase so we must handle the
      connection with the destination and actually perform the
      migration. libxlDomainPerformP2P implements the connection to the
      destination and libxlDoMigrateP2P implements the actual migration
      logic with virConnectPtr. In this function we take care of doing
      all phases of migration in the destination similar to
      virDomainMigrateVersion3Full. We appropriately save the last
      error reported in each of the phases to provide proper reporting.
      We don't yet support VIR_MIGRATE_TUNNELED and we always use V3
      with extensible params, thus it also makes the implementation
      simpler.
      
      It is worth noting that the receiver didn't have any changes, and
      since it's still the v3 sequence thus it is possible to migrate
      from a P2P to non-P2P host.
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      a79da245
  19. 05 2月, 2016 1 次提交
  20. 04 2月, 2016 1 次提交
  21. 04 9月, 2015 1 次提交
  22. 28 8月, 2015 3 次提交
    • J
      libxl: acquire a job when receiving a migrating domain · e80b84a7
      Jim Fehlig 提交于
      Commit f86ae403 moved acquiring a job from libxlDomainStart()
      to its callers. One spot missed was in libxlDoMigrateReceive().
      Acquire a job in libxlDoMigrateReceive() before calling
      libxlDomainStart().
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      e80b84a7
    • J
      libxl: don't attempt to resume domain when suspend fails · 15120b8c
      Jim Fehlig 提交于
      Failure of libxl_domain_suspend() does not leave the domain in
      a suspended state, so no need to call libxl_domain_resume(),
      which btw will fail with "domain not suspended".
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      15120b8c
    • J
      libxl: fix ref counting of libxlMigrationDstArgs · 44a54eb0
      Jim Fehlig 提交于
      This patch fixes some flawed logic around ref counting the
      libxlMigrationDstArgs object.
      
      First, when adding sockets to the event loop with
      virNetSocketAddIOCallback(), the generic virObjectFreeCallback()
      was registered as a free function, with libxlMigrationDstArgs as
      its parameter. A reference was also taken on
      libxlMigrationDstArgs for each successful call to
      virNetSocketAddIOCallback(). The rational behind this logic was
      that the libxlMigrationDstArgs object had to out-live the socket
      objects. But virNetSocketAddIOCallback() already takes a
      reference on socket objects, ensuring their life until removed
      from the event loop and unref'ed in virNetSocketEventFree(). We
      only need to ensure libxlMigrationDstArgs lives until
      libxlDoMigrateReceive() finishes, which can be done by simply
      unref'ing libxlMigrationDstArgs at the end of
      libxlDoMigrateReceive().
      
      The second flaw was unref'ing the sockets in the failure path of
      libxlMigrateReceive() and at the end of libxlDoMigrateReceive().
      As mentioned above, the sockets are already unref'ed by
      virNetSocketEventFree() when removed from the event loop.
      Attempting to unref the socket a second time resulted in a
      libvirtd crash since the socket was previously unref'ed and
      disposed.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      44a54eb0
  23. 09 7月, 2015 1 次提交
    • J
      libxl: rework setting the state of virDomainObj · e9c27344
      Jim Fehlig 提交于
      Set the state of virDomainObj in the functions that
      actually change the domain state, instead of the generic
      libxlDomainCleanup function. This approach gives functions
      calling libxlDomainCleanup more flexibility wrt when and
      how they change virDomainObj state via virDomainObjSetState.
      
      The prior approach of calling virDomainObjSetState in
      libxlDomainCleanup resulted in the following incorrect
      coding pattern in the various functions that change
      domain state
      
       libxlDomain<DoStateTransition>
         call libxl function to do state transition
         emit lifecycle event
         libxlDomainCleanup
           virDomainObjSetState
      
      Once simple manifestation of this bug is seeing a domain
      running in virt-manager after selecting the shutdown button,
      even after the domain has long shutdown.
      e9c27344
  24. 11 6月, 2015 1 次提交
  25. 06 5月, 2015 1 次提交
    • J
      libxl: Resolve Coverity RESOURCE_LEAK · 11b91679
      John Ferlan 提交于
      The returned socks from virNetSocketNewListenTCP needs to be VIR_FREE'd
      as well as seach of the Close/Unref on all the socks[i] that is
      already done
      11b91679
  26. 30 4月, 2015 1 次提交
  27. 21 4月, 2015 1 次提交
    • C
      domain: conf: Drop expectedVirtTypes · 835cf84b
      Cole Robinson 提交于
      This needs to specified in way too many places for a simple validation
      check. The ostype/arch/virttype validation checks later in
      DomainDefParseXML should catch most of the cases that this was covering.
      835cf84b
  28. 17 4月, 2015 1 次提交
    • J
      libxl: drop virDomainObj lock when destroying a domain · 6dfec1ef
      Jim Fehlig 提交于
      A destroy operation can take considerable time on large memory
      domains due to scrubbing the domain's memory.  Unlock the
      virDomainObj while libxl_domain_destroy is executing.
      
      Implement libxlDomainDestroyInternal wrapper to handle unlocking,
      calling destroy, and locking.  Change all callers of
      libxl_domain_destroy to use the wrapper.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      6dfec1ef
  29. 25 3月, 2015 1 次提交
    • J
      libxl: remove per-domain libxl_ctx · a5bf06ba
      Jim Fehlig 提交于
      Although needed in the Xen 4.1 libxl days, there is no longer any
      benefit to having per-domain libxl_ctx.  On the contrary, their use
      makes the code unecessarily complicated and prone to deadlocks under
      load.  As suggested by the libxl maintainers, use a single libxl_ctx
      as a handle to libxl instead of per-domain ctx's.
      
      One downside to using a single libxl_ctx is there are no longer
      per-domain log files for log messages emitted by libxl.  Messages
      for all domains will be sent to /var/log/libvirt/libxl/libxl-driver.log.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      a5bf06ba
  30. 14 1月, 2015 1 次提交
    • D
      Give virDomainDef parser & formatter their own flags · 0ecd6851
      Daniel P. Berrange 提交于
      The virDomainDefParse* and virDomainDefFormat* methods both
      accept the VIR_DOMAIN_XML_* flags defined in the public API,
      along with a set of other VIR_DOMAIN_XML_INTERNAL_* flags
      defined in domain_conf.c.
      
      This is seriously confusing & error prone for a number of
      reasons:
      
       - VIR_DOMAIN_XML_SECURE, VIR_DOMAIN_XML_MIGRATABLE and
         VIR_DOMAIN_XML_UPDATE_CPU are only relevant for the
         formatting operation
       - Some of the VIR_DOMAIN_XML_INTERNAL_* flags only apply
         to parse or to format, but not both.
      
      This patch cleanly separates out the flags. There are two
      distint VIR_DOMAIN_DEF_PARSE_* and VIR_DOMAIN_DEF_FORMAT_*
      flags that are used by the corresponding methods. The
      VIR_DOMAIN_XML_* flags received via public API calls must
      be converted to the VIR_DOMAIN_DEF_FORMAT_* flags where
      needed.
      
      The various calls to virDomainDefParse which hardcoded the
      use of the VIR_DOMAIN_XML_INACTIVE flag change to use the
      VIR_DOMAIN_DEF_PARSE_INACTIVE flag.
      0ecd6851
  31. 02 12月, 2014 1 次提交
    • J
      libxl: Resolve Coverity CHECKED_RETURN · 5f1d3c6c
      John Ferlan 提交于
      Commit id 'cb88d433' refactored the calling sequence to use a thread;
      however, in doing so "lost" the check for if virNetSocketAccept returns
      failure.  Since other code makes that check, Coverity complains. Although
      a false positive, adding back the failure check pacifies Coverity
      5f1d3c6c
  32. 22 11月, 2014 4 次提交
    • J
      libxl: destroy domain in migration finish phase on failure · 42874fa4
      Jim Fehlig 提交于
      This patch contains three domain cleanup improvements in the migration
      finish phase, ensuring a domain is properly disposed when a failure is
      detected or the migration is cancelled.
      
      The check for virDomainObjIsActive is moved to libxlDomainMigrationFinish,
      where cleanup can occur if migration failed and the domain is inactive.
      
      The 'cleanup' label was missplaced in libxlDomainMigrationFinish, causing
      a migrated domain to remain in the event of an error or cancelled migration.
      
      In cleanup, the domain was not removed from the driver's list of domains.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      42874fa4
    • J
      libxl: start domain paused on migration dst · 60386825
      Jim Fehlig 提交于
      During the perform phase of migration, the domain is started on
      the dst host in a running state if VIR_MIGRATE_PAUSED flag is not
      specified.  In the finish phase, the domain is also unpaused if
      VIR_MIGRATE_PAUSED flag is unset.  I've noticed this second unpause
      fails if the domain was already unpaused following the perform phase.
      
      This patch changes the perform phase to always start the domain
      paused, and defers unpausing, if requested, to the finish phase.
      Unpausing should occur in the finish phase anyhow, where the domain
      can be properly destroyed if the perform phase fails and migration
      is cancelled.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      60386825
    • J
      libxl: acquire job in migration finish phase · a1f38951
      Jim Fehlig 提交于
      Moving data reception of the perform phase of migration to a
      thread introduces a race with the finish phase, where checking
      if the domain is active races with the thread finishing the
      perform phase.  The race is easily solved by acquiring a job in
      the finish phase, which must wait for the perform phase job to
      complete.
      
      While wrapping the finish phase in a job, noticed the virDomainObj
      was being unlocked in a callee - libxlDomainMigrationFinish.  Move
      the unlocking to libxlDomainMigrateFinish3Params, where the lock
      is acquired.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      a1f38951
    • J
      libxl: Receive migration data in a thread · cb88d433
      Jim Fehlig 提交于
      The libxl driver receives migration data within an IO callback invoked
      by the event loop, effectively disabling the event loop while migration
      occurs.
      
      This patch moves receving of the migration data to a thread.  The
      incoming connection is still accepted in the IO callback, but control
      is immediately returned to the event loop after spawning the thread.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      cb88d433