1. 19 8月, 2016 1 次提交
    • M
      vz: add validation callbacks · 72abe564
      Mikhail Feoktistov 提交于
      This patch fixes a bug which occurs when we check a bus and unit number
      for a new attached disk. We should do this check in ValidadionCallback,
      not in PostParse callback. Because in PostParse we have not initialized
      disk->info.addr.drive struct yet.
      Move part of code from domainPostParseCallback to domainValidateCallback
      and part from devicesPostParseCallback to deviceValidateCallback.
      PostParse callbacks are for modification data.
      ValidateCallbacks are only for checks.
      72abe564
  2. 07 8月, 2016 1 次提交
  3. 21 7月, 2016 1 次提交
    • N
      vz: make vz driver more responsive · 84299235
      Nikolay Shirokovskiy 提交于
      Current vz driver implementation is not usable when it comes to
      long runnig operations. Migration or saving a domain blocks all
      other operations even query ones which are expecteted to be available.
      This patch addresses this problem.
      
      All vz driver API calls fall into next 3 groups:
      1. only query domain cache (virDomainObj, vz cache statistic)
         examples are vzDomainGetState, vzDomainGetXMLDesc etc.
      2. use thread shared sdkdom object
         examples are vzDomainSetMemoryFlags, vzDomainAttachDevice etc.
      3. use no thread shared sdkdom object nor domain cache
         examples are vzDomainSnapshotListNames, vzDomainSnapshotGetXMLDesc etc
      
      API calls from group 1 don't need to be changed as they hold domain lock only
      for short period of time. These calls [1] are easily distinguished. They query
      domain object thru libvirt common code or query vz sdk statistics handle thru
      vz sdk sync operations.
      
      vzDomainInterfaceStats is the only exception. It uses sdkdom object to
      convert interface name to its vz sdk stack index which could not be saved in
      domain cache. Interface statistics is available thru this stack index as a key
      rather than name. As a result we can have accidental 'not known interface'
      errors on quering intrerface stats. The reason is that in the process of
      updating domain configuration we drop all devices and then recreate them again
      in sdkdom object and domain lock can be dropped meanwhile (to remove networks
      for existing bridged interfaces and(or) (re)create new ones). We can fix this
      by changing the way we support bridged interfaces or by reordering operations
      and changing bridged networks beforehand. Anyway this is better than moving
      this API call into 2 group and making it an exclusive job.
      
      As to API calls from group 2, first thread shared sdkdom object needs to be
      explained. vz sdk has only one handle for a given domain, thus threads need
      exclusive access to operate on it. These calls are fixed to drop and reacquire
      domain lock on any lengthy operations - namely waiting the result of async vz
      sdk operation. As lock is dropped we need to take extra reference to domain
      object if it is not taken already as domain object can be deleted from list
      while lock is dropped. As this operations use thread shared sdkdom object, the
      simplest way to make calls from group 2 be consistent to each other is to make
      them mutually exclusive. This is done by taking/releasing job condition thru
      calling correspondent job routine. This approach makes group 1 and group
      2 calls consistent to each other too. Not all calls of group 2 change the
      domain cache but those that do update it thru prlsdkUpdateDomain which holds
      the lock thoughout the update.
      
      API calls from group [2] are easily distinguished too. They use
      beginEdit/commit to change domain configuration (vzDomainSetMemoryFlags) or/and
      update domain cache from sdkdom at the end of operation (vzDomainSuspend).
      
      There is a known issue however. Frankly speaking it was introduced by ealier
      patch '[PATCH 6/9] vz: cleanup loading domain code' from a different series.
      The patch significantly reduced amount of time when the driver lock is held when
      creating domain from API call or as a result of domain added event from vz sdk.
      The problem is these two paths race on using thread shared sdkdom as we don't
      have libvirt domain object and can not lock on it. However this don't
      invalidates the patch as we can't use the former approach of preadding domain
      into the list as we need name at least and name is not given by event. Anyway
      i'm against adding half baked object into the list. Eventually this race can be
      fixed by extra measures. As to current situation races with different
      configurations are unlikely and race when adding domain thru vz driver and
      simultaneous event from vz sdk is not dangerous as configuration is the same.
      
      The last group [3] is API calls that need only sdkdom object to make vz sdk
      call and don't change thread shared sdkdom object or domain cache in any way.
      For now these are mostly domain snapshot API calls. The changes are similar to
      those of group 2 - they add extra reference and drop/reacquire the lock on waiting
      vz async call result. One can simply take the immutable sdkdom object from the
      cache and drop the lock for the rest of operations but the chosen approach
      makes implementation of these API calls somewhat similar to those of from group
      2 and thus a bit futureproof. As calls of group 3 don't need vz driver
      domain/vz sdk cache in any way, they are consistent with respect to API calls from
      groups 1 and 3.
      
      There is another exception. Calls to make-snapshot/revert-to-snapshot/migrate
      are moved to group 2. That is they are made mutually exclusive. The reason
      is that libvirt API supports control/query only for one job per domain and
      these are jobs that are likely to be queried/aborted.
      
      Appendix.
      
      [1] API calls that only query domain cache.
      (marked [*] are included for a different reason)
      
      .domainLookupByID = vzDomainLookupByID,    /* 0.10.0 */
      .domainLookupByUUID = vzDomainLookupByUUID,        /* 0.10.0 */
      .domainLookupByName = vzDomainLookupByName,        /* 0.10.0 */
      .domainGetOSType = vzDomainGetOSType,    /* 0.10.0 */
      .domainGetInfo = vzDomainGetInfo,  /* 0.10.0 */
      .domainGetState = vzDomainGetState,        /* 0.10.0 */
      .domainGetXMLDesc = vzDomainGetXMLDesc,    /* 0.10.0 */
      .domainIsPersistent = vzDomainIsPersistent,        /* 0.10.0 */
      .domainGetAutostart = vzDomainGetAutostart,        /* 0.10.0 */
      .domainGetVcpus = vzDomainGetVcpus, /* 1.2.6 */
      .domainIsActive = vzDomainIsActive, /* 1.2.10 */
      .domainIsUpdated = vzDomainIsUpdated,     /* 1.2.21 */
      .domainGetVcpusFlags = vzDomainGetVcpusFlags, /* 1.2.21 */
      .domainGetMaxVcpus = vzDomainGetMaxVcpus, /* 1.2.21 */
      .domainHasManagedSaveImage = vzDomainHasManagedSaveImage, /* 1.2.13 */
      .domainGetMaxMemory = vzDomainGetMaxMemory, /* 1.2.15 */
      .domainBlockStats = vzDomainBlockStats, /* 1.2.17 */
      .domainBlockStatsFlags = vzDomainBlockStatsFlags, /* 1.2.17 */
      .domainInterfaceStats = vzDomainInterfaceStats, /* 1.2.17 */                   [*]
      .domainMemoryStats = vzDomainMemoryStats, /* 1.2.17 */
      .domainMigrateBegin3Params = vzDomainMigrateBegin3Params, /* 1.3.5 */
      .domainMigrateConfirm3Params = vzDomainMigrateConfirm3Params, /* 1.3.5 */
      
      [2] API calls that use thread shared sdkdom object
      (marked [*] are included for a different reason)
      
      .domainSuspend = vzDomainSuspend,    /* 0.10.0 */
      .domainResume = vzDomainResume,    /* 0.10.0 */
      .domainDestroy = vzDomainDestroy,  /* 0.10.0 */
      .domainShutdown = vzDomainShutdown, /* 0.10.0 */
      .domainCreate = vzDomainCreate,    /* 0.10.0 */
      .domainCreateWithFlags = vzDomainCreateWithFlags, /* 1.2.10 */
      .domainReboot = vzDomainReboot, /* 1.3.0 */
      .domainDefineXML = vzDomainDefineXML,      /* 0.10.0 */
      .domainDefineXMLFlags = vzDomainDefineXMLFlags, /* 1.2.12 */ (update part)
      .domainUndefine = vzDomainUndefine, /* 1.2.10 */
      .domainAttachDevice = vzDomainAttachDevice, /* 1.2.15 */
      .domainAttachDeviceFlags = vzDomainAttachDeviceFlags, /* 1.2.15 */
      .domainDetachDevice = vzDomainDetachDevice, /* 1.2.15 */
      .domainDetachDeviceFlags = vzDomainDetachDeviceFlags, /* 1.2.15 */
      .domainSetUserPassword = vzDomainSetUserPassword, /* 1.3.6 */
      .domainManagedSave = vzDomainManagedSave, /* 1.2.14 */
      .domainSetMemoryFlags = vzDomainSetMemoryFlags, /* 1.3.4 */
      .domainSetMemory = vzDomainSetMemory, /* 1.3.4 */
      .domainRevertToSnapshot = vzDomainRevertToSnapshot, /* 1.3.5 */                  [*]
      .domainSnapshotCreateXML = vzDomainSnapshotCreateXML, /* 1.3.5 */                [*]
      .domainMigratePerform3Params = vzDomainMigratePerform3Params, /* 1.3.5 */        [*]
      .domainUpdateDeviceFlags = vzDomainUpdateDeviceFlags, /* 2.0.0 */
      prlsdkHandleVmConfigEvent
      
      [3] API calls that do not use thread shared sdkdom object
      
      .domainManagedSaveRemove = vzDomainManagedSaveRemove, /* 1.2.14 */
      .domainSnapshotNum = vzDomainSnapshotNum, /* 1.3.5 */
      .domainSnapshotListNames = vzDomainSnapshotListNames, /* 1.3.5 */
      .domainListAllSnapshots = vzDomainListAllSnapshots, /* 1.3.5 */
      .domainSnapshotGetXMLDesc = vzDomainSnapshotGetXMLDesc, /* 1.3.5 */
      .domainSnapshotNumChildren = vzDomainSnapshotNumChildren, /* 1.3.5 */
      .domainSnapshotListChildrenNames = vzDomainSnapshotListChildrenNames, /* 1.3.5 */
      .domainSnapshotListAllChildren = vzDomainSnapshotListAllChildren, /* 1.3.5 */
      .domainSnapshotLookupByName = vzDomainSnapshotLookupByName, /* 1.3.5 */
      .domainHasCurrentSnapshot = vzDomainHasCurrentSnapshot, /* 1.3.5 */
      .domainSnapshotGetParent = vzDomainSnapshotGetParent, /* 1.3.5 */
      .domainSnapshotCurrent = vzDomainSnapshotCurrent, /* 1.3.5 */
      .domainSnapshotIsCurrent = vzDomainSnapshotIsCurrent, /* 1.3.5 */
      .domainSnapshotHasMetadata = vzDomainSnapshotHasMetadata, /* 1.3.5 */
      .domainSnapshotDelete = vzDomainSnapshotDelete, /* 1.3.5 */
      
      [4] Known issues.
      
      1. accidental errors on getting network statistics
      2. race with simultaneous use of thread shared domain object on paths
       of adding domain thru API and adding domain on vz sdk domain added event.
      84299235
  4. 19 7月, 2016 2 次提交
    • N
      vz: cleanup loading domain code · cfc68155
      Nikolay Shirokovskiy 提交于
        9c14a9ab introduced vzNewDomain function to enlist libvirt domain
      object before actually creating vz sdk domain. Fix should fix
      race on same vz sdk domain added event where libvirt domain object is
      enlisted too. But later eb5e9c1e added locked checks for
      adding livirtd domain object to list on vz sdk domain added event.
      Thus now approach of 9c14a9ab is unnecessary complicated.
      
        See we have otherwise unuseful prlsdkGetDomainIds function only
      to create minimal domain definition to create libvirt domain object.
      Also vzNewDomain is difficult to use as it creates partially
      constructed domain object.
      
        Let's move back to original approach where prlsdkLoadDomain do
      all the necessary job. Another benefit is that we can now
      take driver lock for bare minimum and in single place. Reducing
      locking time have small disadvatage of double parsing on race
      conditions which is typical if domain is added thru vz driver.
      Well we have this double parse inevitably with current vz sdk api
      on any domain updates so i would not take it here seriously.
      
        Performance events subscribtion is done before locked check and
      therefore could be done twice on races but this is not the problem.
      Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
      cfc68155
    • N
  5. 26 6月, 2016 2 次提交
  6. 15 6月, 2016 1 次提交
  7. 11 6月, 2016 1 次提交
  8. 19 5月, 2016 3 次提交
  9. 18 5月, 2016 1 次提交
  10. 13 4月, 2016 4 次提交
  11. 17 3月, 2016 5 次提交
  12. 01 3月, 2016 1 次提交
  13. 12 2月, 2016 2 次提交
    • M
      vz: fix race condition when adding domain to domains list · 9c14a9ab
      Mikhail Feoktistov 提交于
      Race condition:
      User calls defineXML to create new instance.
      The main thread from vzDomainDefineXMLFlags() creates new instance by prlsdkCreateVm.
      Then this thread calls prlsdkAddDomain to add new domain to domains list.
      The second thread receives notification from hypervisor that new VM was created.
      It calls prlsdkHandleVmAddedEvent() and also tries to add new domain to domains list.
      These two threads call virDomainObjListFindByUUID() from prlsdkAddDomain() and don't find new domain.
      So they add two domains with the same uuid to domains list.
      
      This fix splits logic of prlsdkAddDomain() into two functions.
      1. vzNewDomain() creates new empty domain in domains list with the specific uuid.
      2. prlsdkLoadDomain() add data from VM to domain object.
      
      New algorithm for creating an instance:
      In vzDomainDefineXMLFlags() we add new domain to domain list by calling vzNewDomain()
      and only after that we call CreateVm() to create VM.
      It means that we "reserve" domain object with the specific uuid.
      After creation of new VM we add info from this VM
      to reserved domain object by calling prlsdkLoadDomain().
      
      Before this patch prlsdkLoadDomain() worked in 2 different cases:
      1. It creates and initializes new domain. Then updates it from sdk handle.
      2. It updates existed domain from sdk handle.
      In this patch we remove code which creates new domain from LoadDomain()
      and move it to vzNewDomain().
      Now prlsdkLoadDomain() only updates domain from skd handle.
      
      In notification handler prlsdkHandleVmAddedEvent() we check
      the existence of a domain and if it doesn't exist we add new domain by calling
      vzNewDomain() and load info from sdk handle via prlsdkLoadDomain().
      9c14a9ab
    • M
      vz: remove unused struct field · a7b2257e
      Mikhail Feoktistov 提交于
      In commit 7039bb3c we have removed code that saves uuid to vzDomObj.uuid
      So this field is no longer needed.
      a7b2257e
  14. 30 11月, 2015 1 次提交
    • M
      conf: Split virDomainObjList into a separate file · 90f3c0d7
      Michal Privoznik 提交于
      Our domain_conf.* files are big enough. Not only they contain XML
      parsing code, but they served as a storage of all functions whose
      name is virDomain prefixed. This is just wrong as it gathers not
      related functions (and modules) into one big file which is then
      harder to maintain. Split virDomainObjList module into a separate
      file called virdomainobjlist.[ch].
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      90f3c0d7
  15. 08 10月, 2015 1 次提交
  16. 06 10月, 2015 2 次提交
  17. 26 6月, 2015 1 次提交
  18. 17 6月, 2015 2 次提交
  19. 09 6月, 2015 2 次提交
    • D
      parallels: fix formatting errors in parallels driver · ad658a60
      Dmitry Guryanov 提交于
      This patch fixes several formatting errors, which I
      missed before pushing previous patches. Mostly because
      of missing cppi package.
      ad658a60
    • N
      parallels: add block device statistics to driver · 489c81c0
      Nikolay Shirokovskiy 提交于
      Statistics provided through PCS SDK. As we have only async interface in SDK we
      need to be subscribed to statistics in order to get it. Trivial solution on
      every stat request to subscribe, wait event and then unsubscribe will lead to
      significant delays in case of a number of successive requests, as the event
      will be delivered on next PCS server notify cycle. On the other hand we don't
      want to keep unnesessary subscribtion. So we take an hibrid solution to
      subcsribe on first request and then keep a subscription while requests are
      active. We populate cache of statistics on subscribtion events and use this
      cache to serve libvirts requests.
      
       * Cache details.
      Cache is just handle to last arrived event, we call this cache
      as if this handle is valid it is used to serve synchronous
      statistics requests. We use number of successive events count
      to detect that user lost interest to statistics. We reset this
      count to 0 on every request. If more than PARALLELS_STATISTICS_DROP_COUNT
      successive events arrive we unsubscribe. Special value of -1
      of this counter is used to differentiate between subscribed/unsubscribed state
      to protect from delayed events.
      
      Values of PARALLELS_STATISTICS_DROP_COUNT and PARALLELS_STATISTICS_TIMEOUT are
      just drop-ins, choosen without special consideration.
      
       * Thread safety issues
      Use parallelsDomObjFromDomainRef in parallelsDomainBlockStats as
      we could wait on domain lock down on stack in prlsdkGetStatsParam
      and if we won't keep reference we could get dangling pointer
      on return from wait.
      Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@parallels.com>
      489c81c0
  20. 03 6月, 2015 1 次提交
  21. 13 5月, 2015 1 次提交
    • N
      parallels: remove connection wide wait timeout · 2f1f2888
      Nikolay Shirokovskiy 提交于
      We have a lot of passing arguments code just to pass connection
      object cause it holds jobTimeout. Taking into account that
      right now this value is defined at compile time let's just
      get rid of it and make arguments list more clear in many
      places.
      
      In case we later need some runtime configurable timeout
      value we can provide this value through arguments
      function already operate such as a parallels domain
      object etc as this timeouts are operation( and thus
      object) specific in practice.
      Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@parallels.com>
      2f1f2888
  22. 23 4月, 2015 3 次提交
  23. 21 4月, 2015 1 次提交