1. 11 7月, 2019 1 次提交
    • E
      snapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE flag · 95f8e323
      Eric Blake 提交于
      We've been doing a terrible job of performing XML validation in our
      various API that parse XML with a corresponding schema (we started
      with domains back in commit dd69a14f, v1.2.12, but didn't catch all
      domain-related APIs, didn't document the use of the flag, and didn't
      cover other XML). New APIs (like checkpoints) should do the validation
      unconditionally, but it doesn't hurt to continue retrofitting existing
      APIs to at least allow the option.
      
      While there are many APIs that could be improved, this patch focuses
      on wiring up a new snapshot XML creation flag through all the
      hypervisors that support snapshots, as well as exposing it in 'virsh
      snapshot-create'.  For 'virsh snapshot-create-as', we blindly set the
      flag without a command-line option, since the XML we create from the
      command line should generally always comply (note that validation
      might cause failures where it used to succeed, such as if we tighten
      the RNG to reject a name of '../\n'); but blindly passing the flag
      means we also have to add in fallback code to disable validation if
      the server is too old to understand the flag.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Acked-by: NPeter Krempa <pkrempa@redhat.com>
      95f8e323
  2. 09 7月, 2019 1 次提交
    • L
      virsh: support block device storage type in virshParseSnapshotDiskspec · 7ca81e6f
      Liu Dayu 提交于
      virsh snapshot-create-as supports 'file' storage type in --diskspec by default.
      But it doesn't support 'block' storage type in the virshParseSnapshotDiskspec().
      So if a snapshot on a block device (e.g. LV) was created, the type of
      current running storage source in dumpxml is inconsistent with the actual
      backend storage source. It will check file-system type mismatch failed
      and return an error message of 'Migration without shared storage is unsafe'
      when VM performs a live migration after this snapshot.
      
      Considering virsh has to be able to work remotely that recognizing a block device
      by prefix /dev/ or by stat() may be not suitable, so adding a "stype" field
      for the --diskspec string which will be either "file" or "block".
      e.g. --diskspec vda,snapshot=external,driver=qcow2,stype=block,file=/dev/xxx.
      Signed-off-by: NLiu Dayu <liu.dayu@zte.com.cn>
      Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
      7ca81e6f
  3. 20 6月, 2019 1 次提交
  4. 22 3月, 2019 1 次提交
    • E
      snapshot: Refactor list filtering · de80cdbc
      Eric Blake 提交于
      Separate the algorithm for which list members to vist (which is
      generic and can be shared with checkpoints, provided that common
      filtering bits are either declared with the same value or have a
      mapping from public API to common value) from the decision on which
      members to return (which is specific to snapshots).  The typedef for
      the callback function feels a bit heavy here, but will make it easier
      to move the common portions in a later patch.
      
      As part of the refactoring, note that the macros for selecting filter
      bits are specific to listing functionality, so they belong better in
      virdomainsnapshotobjlist.h (missed in commit 9b75154c).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      de80cdbc
  5. 13 3月, 2019 1 次提交
    • E
      virsh: Add snapshot-list --topological · c615c142
      Eric Blake 提交于
      For snapshots, virsh already has a (shockingly naive [1]) client-side
      topological sorter with the --tree option. But as a series of REDEFINE
      calls must be presented in topological order, it's worth letting the
      server do the work for us, especially since the server can give us a
      topological sorting with less effort than our naive client
      reconstruction.
      
      [1] The XXX comment in virshSnapshotListCollect() about --tree being
      O(n^3) is telling; https://en.wikipedia.org/wiki/Topological_sorting
      is an interesting resource describing Kahn's algorithm and other
      approaches for O(n) topological sorting for anyone motivated to use a
      more elegant algorithm than brute force - but that doesn't affect this
      patch.
      
      For now, I am purposefully NOT implementing virsh fallback code to
      provide a topological sort when the flag was rejected as unsupported;
      we can worry about that down the road if users actually demonstrate
      that they use new virsh but old libvirt to even need the fallback.
      (The code we use for --tree could be repurposed to be such a fallback,
      whether or not we keep it naive or improve it to be faster - but
      again, no one should spend time on a fallback without evidence that we
      need it.)
      
      The test driver makes it easy to test:
      $ virsh -c test:///default '
      snapshot-create-as test a
      snapshot-create-as test c
      snapshot-create-as test b
      snapshot-list test
      snapshot-list test --topological
      snapshot-list test --descendants a
      snapshot-list test --descendants a --topological
      snapshot-list test --tree
      snapshot-list test --tree --topological
      '
      
      Without any flags, virsh does client-side sorting alphabetically, and
      lists 'b' before 'c' (even though 'c' is the parent of 'b'); with the
      flag, virsh skips sorting, and you can now see that the server handed
      back data in a correct ordering. As shown here with a simple linear
      chain, there isn't any other possible ordering, so --tree mode doesn't
      seem to care whether --topological is used.  But it is possible to
      compose more complicated DAGs with multiple children to a parent
      (representing reverting back to a snapshot then creating more
      snapshots along those divergent execution timelines), where it is then
      possible (but not guaranteed) that adding the --topological flag
      changes the --tree output (the client-side --tree algorithm breaks
      ties based on alphabetical sorting between two nodes that share the
      same parent, while the --topological sort skips the client-side
      alphabetical sort and ends up exposing the server's internal order for
      siblings, whether that be historical creation order or dependent on a
      random hash seed).  But even if the results differ, they will still be
      topologically correct.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      c615c142
  6. 07 3月, 2019 1 次提交
  7. 27 2月, 2019 1 次提交
  8. 14 2月, 2019 2 次提交
  9. 28 1月, 2019 1 次提交
    • M
      lib: Use more of VIR_STEAL_PTR() · 5772885d
      Michal Privoznik 提交于
      We have this very handy macro called VIR_STEAL_PTR() which steals
      one pointer into the other and sets the other to NULL. The
      following coccinelle patch was used to create this commit:
      
        @ rule1 @
        identifier a, b;
        @@
      
        - b = a;
          ...
        - a = NULL;
        + VIR_STEAL_PTR(b, a);
      
      Some places were clean up afterwards to make syntax-check happy
      (e.g. some curly braces were removed where the body become a one
      liner).
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      5772885d
  10. 03 1月, 2019 1 次提交
  11. 24 9月, 2018 1 次提交
  12. 01 9月, 2018 1 次提交
  13. 10 5月, 2018 1 次提交
  14. 24 1月, 2018 1 次提交
  15. 12 1月, 2018 1 次提交
  16. 04 11月, 2017 1 次提交
  17. 03 11月, 2017 1 次提交
    • A
      Remove backslash alignment attempts · 3e7db8d3
      Andrea Bolognani 提交于
      Right-aligning backslashes when defining macros or using complex
      commands in Makefiles looks cute, but as soon as any changes is
      required to the code you end up with either distractingly broken
      alignment or unnecessarily big diffs where most of the changes
      are just pushing all backslashes a few characters to one side.
      
      Generated using
      
        $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
          grep -E '*\.([chx]|am|mk)$$' | \
          while read f; do \
            sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
          done
      Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
      3e7db8d3
  18. 12 4月, 2017 3 次提交
  19. 25 11月, 2016 1 次提交
    • M
      virstring: Unify string list function names · c2a5a4e7
      Michal Privoznik 提交于
      We have couple of functions that operate over NULL terminated
      lits of strings. However, our naming sucks:
      
      virStringJoin
      virStringFreeList
      virStringFreeListCount
      virStringArrayHasString
      virStringGetFirstWithPrefix
      
      We can do better:
      
      virStringListJoin
      virStringListFree
      virStringListFreeCount
      virStringListHasString
      virStringListGetFirstWithPrefix
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      c2a5a4e7
  20. 14 11月, 2016 1 次提交
  21. 24 8月, 2016 1 次提交
    • P
      virsh: respect -q/--quiet more · b620bdee
      Pino Toscano 提交于
      Turn various vshPrint() informative messages into vshPrintExtra(), so
      they are not printed when requesting the quiet mode; neither XML/info
      outputs nor the results of commands are affected.
      Also change the expected outputs of the virsh-undefine test, since virsh
      is invoked in quiet mode there.
      
      Some informative messages might still be converted (and thus silenced
      when in quiet mode), but this is an improvements nonetheless.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1358179
      b620bdee
  22. 12 1月, 2016 3 次提交
    • J
      virsh: Create macro for common "current" option · 5b42dbed
      John Ferlan 提交于
      Rather than continually cut-n-paste the strings into each command,
      create a common macro to be used generically. The macro will take a
      single argument _helpstr which for many options in virsh-domain.c
      is simply "affect current domain". So, create a second macro within that
      file in order to define the more common use as a revector to the
      common macro with the common _helpstr.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      5b42dbed
    • J
      virsh: Create macro for common "live" option · 8e4108f0
      John Ferlan 提交于
      Rather than continually cut-n-paste the strings into each command,
      create a common macro to be used generically. The macro will take a
      single argument _helpstr which for many options in virsh-domain.c
      is simply "affect running domain". So, create a second macro within that
      file in order to define the more common use as a revector to the
      common macro with the common _helpstr.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      8e4108f0
    • J
      virsh: Create macro for common "domain" option · b6fb1e24
      John Ferlan 提交于
      Rather than continually cut-n-paste the strings into each command,
      create a common macro to be used generically. The macro will take a
      single argument _helpstr which will be used to pass the translatable
      helpstr since not all domain options can take the same string.
      
      The majority of the options take 'N_("domain name, id or uuid")', so
      create a separate macro with a _FULL suffix while those that do not
      take the same string will use the VIRSH_COMMON_OPT_DOMAIN macro.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      b6fb1e24
  23. 14 8月, 2015 1 次提交
    • E
      tools: Introduce new client generic module vsh · 834c5720
      Erik Skultety 提交于
      In order to share as much virsh' logic as possible with upcomming
      virt-admin client we need to split virsh logic into virsh specific and
      client generic features.
      
      Since majority of virsh methods should be generic enough to be used by
      other clients, it's much easier to rename virsh specific data to virshX
      than doing this vice versa. It moved generic virsh commands (including info
      and opts structures) to generic module vsh.c.
      
      Besides renaming methods and structures, this patch also involves introduction
      of a client specific control structure being referenced as private data in the
      original control structure, introduction of a new global vsh Initializer,
      which currently doesn't do much, but there is a potential for added
      functionality in the future.
      Lastly it introduced client hooks which are especially necessary during
      client connecting phase.
      834c5720
  24. 02 6月, 2015 1 次提交
    • A
      virsh: Pass vshControl to all vshCommandOpt*() calls · be6ff4da
      Andrea Bolognani 提交于
      This will allow us to use vshError() to report errors from inside
      vshCommandOpt*(), instead of replicating the same logic and error
      messages all over the place.
      
      We also have more context inside the vshCommandOpt*() functions,
      for example the actual value used on the command line, which means
      we can produce more detailed error messages.
      
      vshCommandOptBool() is the exception here, because it's explicitly
      designed not to report any error.
      be6ff4da
  25. 02 4月, 2015 1 次提交
  26. 12 1月, 2015 1 次提交
  27. 15 11月, 2014 1 次提交
  28. 11 9月, 2014 1 次提交
    • J
      virsh: Resolve Coverity DEADCODE · daf27d4d
      John Ferlan 提交于
      Since 0766783a
      
      Coverity complains that the EDIT_FREE definition results in DEADCODE.
      
      As it turns out with the change to use the EDIT_FREE macro the call to
      vir*Free() wouldn't be necessary nor would it happen...
      
      Prior code to above commitid would :
      
        vir*Ptr foo = NULL;
        ...
        foo = vir*GetXMLDesc()
        ...
        vir*Free(foo);
        foo = vir*DefineXML()
        ...
      
      And thus the free was needed.  With the change to use EDIT_FREE the
      same code changed to:
      
        vir*Ptr foo = NULL;
        vir*Ptr foo_edited = NULL;
        ...
        foo = vir*GetXMLDesc()
        ...
        if (foo_edited)
            vir*Free(foo_edited);
        foo_edited = vir*DefineXML()
        ...
      
      However, foo_edited could never be set in the code path - even with
      all the goto's since the only way for it to be set is if vir*DefineXML()
      succeeds in which case the code to allow a retry (and thus all the goto's)
      never leaves foo_edited set
      
      All error paths lead to "cleanup:" which causes both foo and foo_edited
      to call the respective vir*Free() routines if set.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      daf27d4d
  29. 25 3月, 2014 1 次提交
  30. 14 3月, 2014 1 次提交
  31. 20 8月, 2013 1 次提交
    • P
      virsh: modify vshStringToArray to duplicate the elements too · d64af6ce
      Peter Krempa 提交于
      At a slightly larger memory expense allow stealing of items from the
      string array returned from vshStringToArray and turn the result into a
      string list compatible with virStringSplit. This will allow to use the
      common dealloc function.
      
      This patch also fixes a few forgotten checks of return from
      vshStringToArray and one memory leak.
      d64af6ce
  32. 26 7月, 2013 1 次提交
    • J
      Fix virsh snapshot-list error reporting · e3b21cdc
      Jim Fehlig 提交于
      Noticed that the expected "not supported" error is dropped when
      invoking 'virsh snapshot-list dom' on a Xen installation running
      the libxl driver
      
       virsh snapshot-list test
       error: Invalid snapshot: virDomainSnapshotFree
      
      The error is overwritten by a call to virDomainSnapshotFree
      in cleanup code within cmdSnapshotList.  Prevent overwritting
      the real error by not calling virDomainSnapshotFree with a NULL
      virDomainSnapshotPtr.
      e3b21cdc
  33. 11 7月, 2013 1 次提交
  34. 11 5月, 2013 1 次提交
    • L
      util: move virFile* functions from virutil.c to virfile.c · bfe7721d
      Laine Stump 提交于
      These all existed before virfile.c was created, and for some reason
      weren't moved.
      
      This is mostly straightfoward, although the syntax rule prohibiting
      write() had to be changed to have an exception for virfile.c instead
      of virutil.c.
      
      This movement pointed out that there is a function called
      virBuildPath(), and another almost identical function called
      virFileBuildPath(). They really should be a single function, which
      I'll take care of as soon as I figure out what the arglist should look
      like.
      bfe7721d
  35. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88