1. 12 12月, 2019 1 次提交
  2. 09 12月, 2019 8 次提交
  3. 26 11月, 2019 3 次提交
    • L
      conf: add hypervisor agnostic, domain start-time, validation function for NetDef · b03d9e95
      Laine Stump 提交于
      <interface> devices (virDomainNetDef) are a bit different from other
      types of devices in that their actual type may come from a network (in
      the form of a port connection), and that doesn't happen until the
      domain is started. This means that any validation of an <interface> at
      parse time needs to be a bit liberal in what it accepts - when
      type='network', you could think that something is/isn't allowed, but
      once the domain is started and a port is created by the configured
      network, the opposite might be true.
      
      To solve this problem hypervisor drivers need to do an extra
      validation step when the domain is being started. I recently (commit
      3cff23f7, libvirt 5.7.0) added a function to peform such validation
      for all interfaces to the QEMU driver -
      qemuDomainValidateActualNetDef() - but while that function is a good
      single point to call for the multiple places that need to "start" an
      interface (domain startup, device hotplug, device update), it can't be
      called by the other hypervisor drivers, since 1) it's in the QEMU
      driver, and 2) it contains some checks specific to QEMU. For
      validation that applies to network devices on *all* hypervisors, we
      need yet another interface validation function that can be called by
      any hypervisor driver (not just QEMU) right after its network port has
      been created during domain startup or hotplug. This patch adds that
      function - virDomainActualNetDefValidate(), in the conf directory,
      and calls it in appropriate places in the QEMU, lxc, and libxl
      drivers.
      
      This new function is the place to put all network device validation
      that 1) is hypervisor agnostic, and 2) can't be done until we know the
      "actual type" of an interface.
      
      There is no framework for validation at domain startup as there is for
      post-parse validation, but I don't want to create a whole elaborate
      system that will only be used by one type of device. For that reason,
      I just made a single function that should be called directly from the
      hypervisors, when they are initializing interfaces to start a domain,
      right after conditionally allocating the network port (and regardless
      of whether or not that was actually needed). In the case of the QEMU
      driver, qemuDomainValidateActualNetDef() is already called in all the
      appropriate places, so we can just call the new function from
      there. In the case of the other hypervisors, we search for
      virDomainNetAllocateActualDevice() (which is the hypervisor-agnostic
      function that calls virNetworkPortCreateXML()), and add the call to our
      new function right after that.
      
      The new function itself could be plunked down into many places in the
      code, but we already have 3 validation functions for network devices
      in 2 different places (not counting any basic validation done in
      virDomainNetDefParseXML() itself):
      
      1) post-parse hypervisor-agnostic
         (virDomainNetDefValidate() - domain_conf.c:6145)
      2) post-parse hypervisor-specific
         (qemuDomainDeviceDefValidateNetwork() - qemu_domain.c:5498)
      3) domain-start hypervisor-specific
         (qemuDomainValidateActualNetDef() - qemu_domain.c:5390)
      
      I placed (3) right next to (2) when I added it, specifically to avoid
      spreading validation all over the code. For the same reason, I decided
      to put this new function right next to (1) - this way if someone needs
      to add validation specific to qemu, they go to one location, and if
      they need to add validation applying to everyone, they go to the
      other. It looks a bit strange to have a public function in between a
      bunch of statics, but I think it's better than the alternative of
      further fragmentation. (I'm open to other ideas though, of course.)
      Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NCole Robinson <crobinso@redhat.com>
      b03d9e95
    • L
      conf: return a const from virDomainNetGetActualVirtPortProfile · fdcd273b
      Laine Stump 提交于
      This also isn't required (due to the vportprofile being stored in the
      NetDef as a pointer rather than being directly contained), but it
      seemed dishonest to not mark it as const (and thus permit users to
      modify its contents)
      Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NCole Robinson <crobinso@redhat.com>
      fdcd273b
    • L
      conf: make virDomainNetGetActualBandwidth arg/return value const · 583ac17f
      Laine Stump 提交于
      In this case, the virNetDevBandwidthPtr that is returned is not to a
      region within the virDomainNetDef arg, but points elsewhere (the
      NetDef has the pointer, not the entire object), so technically it's
      not necessary to make the return value a const, but it's a bit
      disingenuous to *not* do it.
      Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NCole Robinson <crobinso@redhat.com>
      583ac17f
  4. 13 11月, 2019 1 次提交
  5. 12 11月, 2019 1 次提交
  6. 25 10月, 2019 1 次提交
  7. 24 10月, 2019 1 次提交
    • M
      Drop needless ret variable · 3b4df5d3
      Michal Privoznik 提交于
      In few places we have the following code pattern:
      
        int ret;
        ... /* @ret is not accessed here */
        ret = f(...);
        return ret;
      
      This pattern can be written less verbose:
      
        ...
        return f(...);
      
      This patch was generated with following coccinelle spatch:
      
        @@
        type T;
        constant C;
        expression f;
        identifier ret;
        @@
        -T ret = C;
         ... when != ret
        -ret = f;
        -return ret;
        +return f;
      
      Afterwards I needed to fix a few places, e.g. comment in
      virDomainNetIPParseXML() was removed too because coccinelle
      thinks it refers to @ret while in fact it doesn't. Also in few
      places it replaced @ret declaration with a few spaces instead of
      removing the line. But nothing terribly wrong.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      3b4df5d3
  8. 21 10月, 2019 3 次提交
  9. 17 10月, 2019 1 次提交
  10. 15 10月, 2019 1 次提交
  11. 14 10月, 2019 1 次提交
  12. 08 10月, 2019 1 次提交
  13. 27 9月, 2019 1 次提交
    • L
      conf: utility function to update entry in def->nets array · 7e490cda
      Laine Stump 提交于
      A virDomainNetDef object in a domain's nets array might contain a
      virDomainHostdevDef, and when this is the case, the domain's hostdevs
      array will also have a pointer to this embedded hostdev (this is done
      so that internal functions that need to perform some operation on all
      hostdevs won't leave out the type='hostdev' network interfaces).
      
      When a network device was updated with virDomainUpdateDeviceFlags(),
      we were replacing the entry in the nets array (and free'ing the
      original) but forgetting about the pointer in the hostdevs array
      (which would then point to the now-free'd hostdev contained in the old
      net object.) This often resulted in a libvirtd crash.
      
      The solution is to add a function, virDomainNetUpdate(), called by
      qemuDomainUpdateDeviceConfig(), that updates the hostdevs array
      appropriately along with the nets array.
      
      Resolves: https://bugzilla.redhat.com/1558934Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      7e490cda
  14. 09 8月, 2019 3 次提交
    • D
      remote: in per-driver daemons ensure that state initialize succeeds · 4ce29411
      Daniel P. Berrangé 提交于
      When running in libvirtd, we are happy for any of the drivers to simply
      skip their initialization in virStateInitialize, as other drivers are
      still potentially useful.
      
      When running in per-driver daemons though, we want the daemon to abort
      startup if the driver cannot initialize itself, as the daemon will be
      useless without it.
      Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      4ce29411
    • J
      qemu: Pass correct qemuCaps to virDomainDeviceDefPostParse · b449c270
      Jiri Denemark 提交于
      Since qemuDomainDeviceDefPostParse callback requires qemuCaps, we need
      to make sure it gets the capabilities stored in the domain's private
      data if the domain is running. Passing NULL may cause QEMU capabilities
      probing to be triggered in case QEMU binary changed in the meantime.
      When this happens while a running domain object is locked, QMP event
      delivered to the domain before QEMU capabilities probing finishes will
      deadlock the event loop.
      
      QEMU capabilities lookup (via domainPostParseDataAlloc callback) is
      hidden inside virDomainDeviceDefPostParseOne with no way to pass
      qemuCaps to virDomainDeviceDef* functions. This patch fixes all
      remaining paths leading to virDomainDeviceDefPostParse.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      b449c270
    • J
      qemu: Pass correct qemuCaps to virDomainDefCopy · bbcfa07b
      Jiri Denemark 提交于
      Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
      sure it gets the capabilities stored in the domain's private data if the
      domain is running. Passing NULL may cause QEMU capabilities probing to
      be triggered in case QEMU binary changed in the meantime. When this
      happens while a running domain object is locked, QMP event delivered to
      the domain before QEMU capabilities probing finishes will deadlock the
      event loop.
      
      Several general functions from domain_conf.c were lazily passing NULL as
      the parseOpaque pointer instead of letting their callers pass the right
      data. This patch fixes all paths leading to virDomainDefCopy to do the
      right thing.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      bbcfa07b
  15. 15 7月, 2019 1 次提交
  16. 11 7月, 2019 1 次提交
    • D
      lxc: acquire a pidfile in the driver root directory · 64c5b6bc
      Daniel P. Berrangé 提交于
      When we allow multiple instances of the driver for the same user
      account, using a separate root directory, we need to ensure mutual
      exclusion. Use a pidfile to guarantee this.
      
      In privileged libvirtd this ends up locking
      
         /var/run/libvirt/lxc/driver.pid
      
      In unprivileged libvirtd this ends up locking
      
        /run/user/$UID/libvirt/lxc/run/driver.pid
      
      NB, the latter can vary depending on $XDG_RUNTIME_DIR
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      64c5b6bc
  17. 30 4月, 2019 2 次提交
  18. 26 4月, 2019 1 次提交
  19. 18 4月, 2019 1 次提交
  20. 16 4月, 2019 2 次提交
  21. 18 3月, 2019 1 次提交
  22. 08 3月, 2019 1 次提交
  23. 06 3月, 2019 1 次提交
  24. 20 2月, 2019 1 次提交
    • E
      domain: Fix unknown flags diagnosis in virDomainGetXMLDesc · 27c8fd74
      Eric Blake 提交于
      Many drivers had a comment that they did not validate the incoming
      'flags' to virDomainGetXMLDesc() because they were relying on
      virDomainDefFormat() to do it instead. This used to be the case
      (at least since 461e0f1a and friends in 0.9.4 added unknown flag
      checking in general), but regressed in commit 0ecd6851 (1.2.12),
      when all of the drivers were changed to pass 'flags' through the
      new helper virDomainDefFormatConvertXMLFlags(). Since this helper
      silently ignores unknown flags, we need to implement flag checking
      in each driver instead.
      
      Annoyingly, this means that any new flag values added will silently
      be ignored when targeting an older libvirt, rather than our usual
      practice of loudly diagnosing an unsupported flag.  Add comments
      in domain_conf.[ch] to remind us to be extra vigilant about the
      impact when adding flags (a new flag to add data is safe if the
      older server omitting the requested data doesn't break things in
      the newer client; a new flag to suppress data rather than enhancing
      the existing VIR_DOMAIN_XML_SECURE may form a data leak or even a
      security hole).
      
      In the qemu driver, there are multiple callers all funnelling to
      qemuDomainDefFormatBufInternal(); many of them already validated
      flags (and often only a subset of the full set of possible flags),
      but for ease of maintenance, we can also check flags at the common
      helper function.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      27c8fd74
  25. 07 2月, 2019 1 次提交
    • M
      lxc: Don't reboot host on virDomainReboot · 94fce255
      Michal Privoznik 提交于
      If the container is really a simple one (init is just bash and
      the whole root is passed through) then virDomainReboot and
      virDomainShutdown will talk to the actual init within the host.
      Therefore, 'virsh shutdown $dom' will result in shutting down the
      host. True, at that point the container is shut down too but
      looks a bit harsh to me.
      
      The solution is to check if the init inside the container is or
      is not the same as the init running on the host.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      94fce255