1. 03 7月, 2014 3 次提交
    • M
      qemu: Implement virConnectGetDomainCapabilities · 94e3f23e
      Michal Privoznik 提交于
      So far only information on disks and host devices are exposed in the
      capabilities XML. Well, at least something. Even a new test is
      introduced. The qemu capabilities are stolen from already existing
      qemucapabilities test. There's one tricky point though. Functions that
      checks host's KVM and VFIO capabilities, are impossible to mock
      currently. So in the test, we are setting the capabilities by hand.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      94e3f23e
    • M
      Introduce domain_capabilities · 614581f3
      Michal Privoznik 提交于
      This new module holds and formats capabilities for emulator. If you
      are about to create a new domain, you may want to know what is the
      host or hypervisor capable of. To make sure we don't regress on the
      XML, the formatting is not something left for each driver to
      implement, rather there's general format function.
      
      The domain capabilities is a lockable object (even though the locking
      is not necessary yet) which uses reference counter.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      614581f3
    • J
      Introduce virBufferCheckError · 058d89b9
      Ján Tomko 提交于
      Check if the buffer is in error state and report an error if it is.
      
      This replaces the pattern:
      if (virBufferError(buf)) {
          virReportOOMError();
          goto cleanup;
      }
      with:
      
      if (virBufferCheckError(buf) < 0)
          goto cleanup;
      
      Document typical buffer usage to favor this.
      Also remove the redundant FreeAndReset - if an error has
      been set via virBufferSetError, the content is already freed.
      058d89b9
  2. 01 7月, 2014 1 次提交
    • J
      Introduce virFileReadAllQuiet · f638c13e
      Ján Tomko 提交于
      Just like virFileReadAll, but returns -errno instead
      of reporting errors. Useful for ignoring some errors.
      f638c13e
  3. 26 6月, 2014 2 次提交
  4. 25 6月, 2014 1 次提交
    • P
      util: storage: Add helper to resolve relative path difference · 157a33a7
      Peter Krempa 提交于
      This patch introduces a function that will allow us to resolve a
      relative difference between two elements of a disk backing chain. This
      function will be used to allow relative block commit and block pull
      where we need to specify the new relative name of the image to qemu.
      
      This patch also adds unit tests for the function to verify that it works
      correctly.
      157a33a7
  5. 24 6月, 2014 3 次提交
  6. 21 6月, 2014 1 次提交
  7. 20 6月, 2014 2 次提交
  8. 19 6月, 2014 5 次提交
    • M
      nodeinfo: Implement nodeGetFreePages · 38fa03f4
      Michal Privoznik 提交于
      And add stubs to other drivers like: lxc, qemu, uml and vbox.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      38fa03f4
    • M
      virnuma: Introduce pages helpers · 35f1095e
      Michal Privoznik 提交于
      For future work we need two functions that fetches total number of
      pages and number of free pages for given NUMA node and page size
      (virNumaGetPageInfo()).
      
      Then we need to learn pages of what sizes are supported on given node
      (virNumaGetPages()).
      
      Note that system page size is disabled at the moment as there's one
      issue connected. If you have a NUMA node with huge pages allocated the
      kernel would return the normal size of memory for that node. It
      basically ignores the fact that huge pages steal size from the system
      memory. Until we resolve this, it's safer to not confuse users and
      hence not report any system pages yet.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      35f1095e
    • M
      nodeinfo: Rename nodeGetFreeMemory to nodeGetMemory · 99a63aed
      Michal Privoznik 提交于
      For future work we want to get info for not only the free memory
      but overall memory size too. That's why the function must have
      new signature too.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      99a63aed
    • M
      virnuma: Introduce virNumaNodeIsAvailable · 356c6f38
      Michal Privoznik 提交于
      Not on all hosts the set of NUMA nodes IDs is continuous. This is
      critical, because our code currently assumes the set doesn't contain
      holes. For instance in nodeGetFreeMemory() we can see the following
      pattern:
      
          if ((max_node = virNumaGetMaxNode()) < 0)
              return 0;
      
          for (n = 0; n <= max_node; n++) {
              ...
          }
      
      while it should be something like this:
      
          if ((max_node = virNumaGetMaxNode()) < 0)
              return 0;
      
          for (n = 0; n <= max_node; n++) {
              if (!virNumaNodeIsAvailable(n))
                  continue;
              ...
          }
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      356c6f38
    • E
      blockjob: use stable disk string in job event · 1bfe73a1
      Eric Blake 提交于
      When the block job event was first added, it was for block pull,
      where the active layer of the disk remains the same name.  It was
      also in a day where we only cared about local files, and so we
      always had a canonical absolute file name.  But two things have
      changed since then: we now have network disks, where determining
      a single absolute string does not really make sense; and we have
      two-phase jobs (copy and active commit) where the name of the
      active layer changes between the first event (ready, on the old
      name) and second (complete, on the pivoted name).
      
      Adam Litke reported that having an unstable string between events
      makes life harder for clients.  Furthermore, all of our API that
      operate on a particular disk of a domain accept multiple strings:
      not only the absolute name of the active layer, but also the
      destination device name (such as 'vda').  As this latter name is
      stable, even for network sources, it serves as a better string
      to supply in block job events.
      
      But backwards-compatibility demands that we should not change the
      name handed to users unless they explicitly request it.  Therefore,
      this patch adds a new event, BLOCK_JOB_2 (alas, I couldn't think of
      any nicer name - but at least Migrate2 and Migrate3 are precedent
      for a number suffix).  We must double up on emitting both old-style
      and new-style events according to what clients have registered for
      (see also how IOError and IOErrorReason emits double events, but
      there the difference was a larger struct rather than changed
      meaning of one of the struct members).
      
      Unfortunately, adding a new event isn't something that can easily
      be broken into pieces, so the commit is rather large.
      
      * include/libvirt/libvirt.h.in (virDomainEventID): Add a new id
      for VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2.
      (virConnectDomainEventBlockJobCallback): Document new semantics.
      * src/conf/domain_event.c (_virDomainEventBlockJob): Rename field,
      to ensure we catch all clients.
      (virDomainEventBlockJobNew): Add parameter.
      (virDomainEventBlockJobDispose)
      (virDomainEventBlockJobNewFromObj)
      (virDomainEventBlockJobNewFromDom)
      (virDomainEventDispatchDefaultFunc): Adjust clients.
      (virDomainEventBlockJob2NewFromObj)
      (virDomainEventBlockJob2NewFromDom): New functions.
      * src/conf/domain_event.h: Add new prototypes.
      * src/libvirt_private.syms (domain_event.h): Export new functions.
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Generate two
      different events.
      * src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Likewise.
      * src/remote/remote_protocol.x
      (remote_domain_event_block_job_2_msg): New struct.
      (REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2): New RPC.
      * src/remote/remote_driver.c
      (remoteDomainBuildEventBlockJob2): New handler.
      (remoteEvents): Register new event.
      * daemon/remote.c (remoteRelayDomainEventBlockJob2): New handler.
      (domainEventCallbacks): Register new event.
      * tools/virsh-domain.c (vshEventCallbacks): Likewise.
      (vshEventBlockJobPrint): Adjust client.
      * src/remote_protocol-structs: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1bfe73a1
  9. 16 6月, 2014 1 次提交
  10. 11 6月, 2014 2 次提交
    • M
      virnetdev: Introduce virNetDevGetLinkInfo · 05630cf4
      Michal Privoznik 提交于
      The purpose of this function is to fetch link state
      and link speed for given NIC name from the SYSFS.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      05630cf4
    • M
      virInterface: Expose link state & speed · 3db89662
      Michal Privoznik 提交于
      Currently it is not possible to determine the speed of an interface
      and whether a link is actually detected from the API. Orchestrating
      platforms want to be able to determine when the link has failed and
      where multiple speeds may be available which one the interface is
      actually connected at. This commit introduces an extension to our
      interface XML (without implementation to interface driver backends):
      
        <interface type='ethernet' name='eth0'>
          <start mode='none'/>
          <mac address='aa:bb:cc:dd:ee:ff'/>
          <link speed='1000' state='up'/>
          <mtu size='1492'/>
          ...
        </interface>
      
      Where @speed is negotiated link speed in Mbits per second, and state
      is the current NIC state (can be one of the following:  "unknown",
      "notpresent", "down", "lowerlayerdown","testing", "dormant", "up").
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      3db89662
  11. 06 6月, 2014 2 次提交
    • E
      conf: consolidate disk def allocation · bc3f5f19
      Eric Blake 提交于
      A future patch wants to create disk definitions with non-zero
      default contents; to avoid crashes, all callers that allocate
      a disk definition should go through a common point.
      
      I found allocation points by looking for any code that increments
      ndisks, as well as any matches for ALLOC.*disk.  Most places that
      modified ndisks were covered by the parse from XML to domain/device
      definition by initial domain creation or device hotplug; I also
      hand-checked all drivers that generate a device struct on the
      fly during getXMLDesc.
      
      * src/conf/domain_conf.h (virDomainDiskDefNew): New prototype.
      * src/conf/domain_conf.c (virDomainDiskDefNew): New function.
      (virDomainDiskDefParseXML): Use it.
      * src/parallels/parallels_driver.c (parallelsAddHddInfo):
      Likewise.
      * src/qemu/qemu_command.c (qemuParseCommandLine): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc): Likewise.
      * src/vmx/vmx.c (virVMXParseDisk): Likewise.
      * src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr):
      Likewise.
      * src/xenxs/xen_xm.c (xenParseXM): Likewise.
      * src/libvirt_private.syms (domain_conf.h): Export it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      bc3f5f19
    • J
      Introduce virBitmapDataToString · 7d8afc47
      Ján Tomko 提交于
      For converting bitmap data to human-readable strings.
      7d8afc47
  12. 04 6月, 2014 1 次提交
  13. 03 6月, 2014 4 次提交
    • P
      util: string: Return element count from virStringSplit · 68226749
      Peter Krempa 提交于
      To allow using the array manipulation macros on the arrays returned by
      virStringSplit we need to know the count of the elements in the array.
      Modify virStringSplit to return this value, rename it and add a helper
      with the old name so that we don't need to update all the code.
      68226749
    • P
      storage: Add infrastructure to parse remote network backing names · ed68eb86
      Peter Krempa 提交于
      Add parsers for relative and absolute backing names for local and remote
      storage files.
      
      This parser parses relative paths as relative to their parents and
      absolute paths according to the protocol or local access.
      
      For remote storage volumes, all URI based backing file names are
      supported and for the qemu colon syntax the NBD protocol is supported.
      ed68eb86
    • P
      storage: Switch metadata crawler to use storage driver to read headers · 2bdb8b96
      Peter Krempa 提交于
      Use virStorageFileReadHeader() to read headers of storage files possibly
      on remote storage to retrieve the image metadata.
      
      The backend information is now parsed by
      virStorageFileGetMetadataInternal which is now exported from the util
      source and virStorageFileGetMetadataFromFDInternal now doesn't need to
      be exported.
      2bdb8b96
    • P
      storage: Move virStorageFileGetMetadata to the storage driver · 713cc3b0
      Peter Krempa 提交于
      My future work will modify the metadata crawler function to use the
      storage driver file APIs to access the files instead of accessing them
      directly so that we will be able to request the metadata for remote
      files too. To avoid linking the storage driver to every helper file
      using the utils code, the backing chain traversal function needs to be
      moved to the storage driver source.
      
      Additionally the virt-aa-helper and virstoragetest programs need to be
      linked with the storage driver as a result of this change.
      713cc3b0
  14. 26 5月, 2014 1 次提交
    • L
      util: new function virTimeLocalOffsetFromUTC · 1cddaea7
      Laine Stump 提交于
      Since there isn't a single libc API to get this value, this patch
      supplies one which gets the value by grabbing current time, then
      converting that into a struct tm with gmtime_r(), then back to a
      time_t using mktime.
      
      The returned value is the difference between UTC and localtime in
      seconds. If localtime is ahead of UTC (east) the offset will be a
      positive number, and if localtime is behind UTC (west) the offset will
      be negative.
      
      This function should be POSIX-compliant, and is threadsafe, but not
      async signal safe. If it was ever necessary to know this value in a
      child process, we could cache it with a one-time init function when
      libvirtd starts, then just supply the cached value, but that
      complexity isn't needed for current usage; that would also have the
      problem that it might not be accurate after a local daylight savings
      boundary.
      
      (If it weren't for DST, we could simply replace this entire function
      with "-timezone"; timezone contains the offset of the current timezone
      (negated from what we want) but doesn't account for DST. And in spite
      of being guaranteed by POSIX, it isn't available on older versions of
      mingw.)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1cddaea7
  15. 16 5月, 2014 1 次提交
    • E
      maint: shorten 'TypeType' function names · ab517818
      Eric Blake 提交于
      The VIR_ENUM_DECL/VIR_ENUM_IMPL helper macros already append 'Type'
      to the enum name being converted; it looks silly to have functions
      with 'TypeType' in their name.  Even though some of our enums have
      to have a 'Type' suffix, the corresponding string conversion
      functions do not.
      
      * src/conf/secret_conf.h (VIR_ENUM_DECL): Rename virSecretUsageType.
      * src/conf/storage_conf.h (VIR_ENUM_DECL): Rename
      virStoragePoolAuthType, virStoragePoolSourceAdapterType,
      virStoragePartedFsType.
      * src/conf/domain_conf.c (virDomainDiskDefParseXML)
      (virDomainFSDefParseXML, virDomainFSDefFormat): Update callers.
      * src/conf/secret_conf.c (virSecretDefParseUsage)
      (virSecretDefFormatUsage): Likewise.
      * src/conf/storage_conf.c (virStoragePoolDefParseAuth)
      (virStoragePoolDefParseSource, virStoragePoolSourceFormat):
      Likewise.
      * src/lxc/lxc_controller.c (virLXCControllerSetupLoopDevices):
      Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskPartFormat): Likewise.
      * src/util/virstorageencryption.c (virStorageEncryptionSecretParse)
      (virStorageEncryptionSecretFormat): Likewise.
      * tools/virsh-secret.c (cmdSecretList): Likewise.
      * src/libvirt_private.syms (secret_conf.h, storage_conf.h): Export
      corrected names.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ab517818
  16. 14 5月, 2014 1 次提交
    • R
      qemu: extract common PCI handling functions · 353cf370
      Roman Bogorodskiy 提交于
      Move sharable PCI handling functions to domain_addr.[ch], and
      change theirs prefix from 'qemu' to 'vir':
      
       - virDomainPCIAddressAsString;
       - virDomainPCIAddressBusSetModel;
       - virDomainPCIAddressEnsureAddr;
       - virDomainPCIAddressFlagsCompatible;
       - virDomainPCIAddressGetNextSlot;
       - virDomainPCIAddressReleaseSlot;
       - virDomainPCIAddressReserveAddr;
       - virDomainPCIAddressReserveNextSlot;
       - virDomainPCIAddressReserveSlot;
       - virDomainPCIAddressSetFree;
       - virDomainPCIAddressSetGrow;
       - virDomainPCIAddressSlotInUse;
       - virDomainPCIAddressValidate;
      
      The only change here is function names, the implementation itself
      stays untouched.
      
      Extract common allocation code from DomainPCIAddressSetCreate
      into virDomainPCIAddressSetAlloc.
      353cf370
  17. 06 5月, 2014 2 次提交
    • C
      virdbus: Make virDBusCall static · 709f2455
      Cole Robinson 提交于
      709f2455
    • E
      conf: drop extra storage probe · fff74b27
      Eric Blake 提交于
      All callers of virStorageFileGetMetadataFromBuf were first calling
      virStorageFileProbeFormatFromBuf, to learn what format to pass in.
      But this function is already wired to do the exact same probe if
      the incoming format is VIR_STORAGE_FILE_AUTO, so it's simpler to
      just refactor the probing into the central function.
      
      * src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
      Drop parameter.
      (virStorageFileProbeFormatFromBuf): Drop declaration.
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
      Do probe here instead of in callers.
      (virStorageFileProbeFormatFromBuf): Make static.
      * src/libvirt_private.syms (virstoragefile.h): Drop function.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Update caller.
      * src/storage/storage_backend_gluster.c
      (virStorageBackendGlusterRefreshVol): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      fff74b27
  18. 02 5月, 2014 1 次提交
    • E
      util: new stricter unsigned int parsing · 7b045c8c
      Eric Blake 提交于
      strtoul() is required to parse negative numbers as their
      twos-complement positive counterpart.  But sometimes we want
      to reject negative numbers.  Add new functions to do this.
      The 'p' suffix is a mnemonic for 'positive' (technically it
      also parses 0, but 'non-negative' doesn't lend itself to a
      nice one-letter suffix).
      
      * src/util/virstring.h (virStrToLong_uip, virStrToLong_ulp)
      (virStrToLong_ullp): New prototypes.
      * src/util/virstring.c (virStrToLong_uip, virStrToLong_ulp)
      (virStrToLong_ullp): New functions.
      * src/libvirt_private.syms (virstring.h): Export them.
      * tests/virstringtest.c (testStringToLong): Test them.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7b045c8c
  19. 01 5月, 2014 1 次提交
  20. 29 4月, 2014 2 次提交
  21. 25 4月, 2014 3 次提交
    • D
      Add a test suite for nwfilter ebiptables tech driver · 3ba789cc
      Daniel P. Berrange 提交于
      Create a nwfilterxml2firewalltest to exercise the
      ebiptables_driver.applyNewRules method with a variety of
      different XML input files. The XML input files are taken
      from the libvirt-tck nwfilter tests. While the nwfilter
      tests verify the final state of the iptables chains, this
      test verifies the set of commands invoked to create the
      chains.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      3ba789cc
    • D
      Introduce an object for managing firewall rulesets · 3a0ca7de
      Daniel P. Berrange 提交于
      The network and nwfilter drivers both have a need to update
      firewall rules. The currently share no code for interacting
      with iptables / firewalld. The nwfilter driver is fairly
      tied to the concept of creating shell scripts to execute
      which makes it very hard to port to talk to firewalld via
      DBus APIs.
      
      This patch introduces a virFirewallPtr object which is able
      to represent a complete sequence of rule changes, with the
      ability to have multiple transactional checkpoints with
      rollbacks. By formally separating the definition of the rules
      to be applied from the mechanism used to apply them, it is
      also possible to write a firewall engine that uses firewalld
      DBus APIs natively instead of via the slow firewalld-cmd.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      3a0ca7de
    • D
      Add helper methods for determining what protocol layer is used · 23b1d0c0
      Daniel P. Berrange 提交于
      Add virNWFilterRuleIsProtocol{Ethernet,IPv4,IPv6} helper methods
      to avoid having to write a giant switch statements with many cases.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      23b1d0c0