1. 29 6月, 2011 1 次提交
    • L
      network: add domain to unqualified names defined with <host> · 25171f60
      Laine Stump 提交于
      If a domain name is defined for a network, add the --expand-hosts
      option to the dnsmasq commandline. This results in the domain being
      added to any hostname that is defined in a dns <host> element and
      contains no '.' characters (i.e. it is an "unqualified"
      hostname). Since PTR records are automatically created for any name
      defined in <host>, the result of a PTR request will change from the
      unqualified name to the qualified name.
      
      This also has the same effect on any hostnames that dnsmasq reads
      from the host's /etc/hosts file.
      
      (In the case of guest hostnames that were learned by dnsmasq via DHCP
      requests, they were already getting the domain name added on, even
      without --expand-hosts).
      25171f60
  2. 27 6月, 2011 2 次提交
  3. 25 6月, 2011 4 次提交
  4. 21 6月, 2011 1 次提交
    • C
      Promote virEvent*Handle/Timeout to public API · 6094ad7b
      Cole Robinson 提交于
      Since we virEventRegisterDefaultImpl is now a public API, callers need
      a way to invoke the default registered Handle and Timeout functions. We
      already have general functions for these internally, so promote
      them to the public API.
      
      v2:
          Actually add APIs to libvirt.h
      6094ad7b
  5. 16 5月, 2011 2 次提交
    • D
      Add many version number annotations to drivers · 9b1ae97f
      Daniel P. Berrange 提交于
      Add many version number annotations to the internal driver
      tables, to allow hvsupport.html to display more accurate
      information
      9b1ae97f
    • D
      Convert all driver struct intializers to C99 style · 879d409e
      Daniel P. Berrange 提交于
      Change all the driver struct initializers to use the
      C99 style, leaving out unused fields. This will make
      it possible to add new APIs without changing every
      driver. eg change:
      
          qemudDomainResume, /* domainResume */
          qemudDomainShutdown, /* domainShutdown */
          NULL, /* domainReboot */
          qemudDomainDestroy, /* domainDestroy */
      
      to
      
          .domainResume = qemudDomainResume,
          .domainShutdown = qemudDomainShutdown,
          .domainDestroy = qemudDomainDestroy,
      
      And get rid of any existing C99 style initializersr which
      set NULL, eg change
      
           .listPools          = vboxStorageListPools,
           .numOfDefinedPools  = NULL,
           .listDefinedPools   = NULL,
           .findPoolSources    = NULL,
           .poolLookupByName   = vboxStoragePoolLookupByName,
      
      to
      
           .listPools          = vboxStorageListPools,
           .poolLookupByName   = vboxStoragePoolLookupByName,
      879d409e
  6. 12 5月, 2011 2 次提交
    • E
      maint: omit translation for all VIR_INFO · cb84580a
      Eric Blake 提交于
      We were 31/73 on whether to translate; since less than 50% translated
      and since VIR_INFO is less than VIR_WARN which also doesn't translate,
      this makes sense.
      
      * cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
      falls between WARN and DEBUG.
      * daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
      (qemudDispatchServer): Adjust offenders.
      * daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
      * src/network/bridge_driver.c (networkReloadIptablesRules)
      (networkStartNetworkDaemon, networkShutdownNetworkDaemon)
      (networkCreate, networkDefine, networkUndefine): Likewise.
      * src/qemu/qemu_driver.c (qemudDomainDefine)
      (qemudDomainUndefine): Likewise.
      * src/storage/storage_driver.c (storagePoolCreate)
      (storagePoolDefine, storagePoolUndefine, storagePoolStart)
      (storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
      (storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
      * src/util/bridge.c (brProbeVnetHdr): Likewise.
      * po/POTFILES.in: Drop src/util/bridge.c.
      cb84580a
    • L
      libvirt,logging: cleanup VIR_XXX0() · b65f37a4
      Lai Jiangshan 提交于
      These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.
      
      How do these coversions works? The magic is using the gcc extension of ##.
      When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
      avoid compile error.
      
      example: origin				after CPP
      	high_level_api("%d", a_int)	low_level_api("%d", a_int)
      	high_level_api("a  string")	low_level_api("a  string")
      
      About 400 conversions.
      
      8 special conversions:
      VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions
      VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
      VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
        (for security) 6 conversions
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      b65f37a4
  7. 11 5月, 2011 1 次提交
    • M
      Rename internal DumpXML functions to GetXMLDesc · 9817604a
      Matthias Bolte 提交于
      This matches the public API and helps to get rid of some special
      case code in the remote generator.
      
      Rename driver API functions and XDR protocol structs.
      
      No functional change included outside of the remote generator.
      9817604a
  8. 06 5月, 2011 1 次提交
    • E
      maint: rename virBufferVSprintf to virBufferAsprintf · 68ea80cf
      Eric Blake 提交于
      We already have virAsprintf, so picking a similar name helps for
      seeing a similar purpose.  Furthermore, the prefix V before printf
      generally implies 'va_list', even though this variant was '...', and
      the old name got in the way of adding a new va_list version.
      
      global rename performed with:
      
      $ git grep -l virBufferVSprintf \
        | xargs -L1 sed -i 's/virBufferVSprintf/virBufferAsprintf/g'
      
      then revert the changes in ChangeLog-old.
      68ea80cf
  9. 26 4月, 2011 1 次提交
  10. 17 4月, 2011 1 次提交
  11. 15 4月, 2011 1 次提交
    • L
      network: truncate bridges' dummy tap device names to IFNAMSIZ (15) chars · 020ad8d1
      Laine Stump 提交于
      This patch addresses:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=694382
      
      In order to give each libvirt-created bridge a fixed MAC address,
      commit 5754dbd5, added code to create
      a dummy tap device with guaranteed lowest MAC address and attach it to
      the bridge. This tap device was given the name "${bridgename}-nic".
      However, an interface device name must be IFNAMSIZ (15) characters or
      less, so a valid ${bridgename} such as "verylongname123" (15
      characters) would lead to an invalid tap device name
      ("verylongname123-nic" - 19 characters), and that in turn led to a
      failure to bring up the network.
      
      The solution is to shorten the part of the original name used to
      generate the tap device name. However, simply truncating it is
      insufficient, because the last few characters of an interface name are
      often a number used to indicate one of a list of several similar
      devices (for example, "verylongname123", "verylongname124", etc) and
      simple truncation would lead to duplicate names (eg "verlongnam-nic"
      and "verylongnam-nic"). So instead we take the first 8 characters of
      $bridgename ("verylong" in the example), add on the final 3 bytes
      ("123"), then add "-nic" (so "verylong123-nic").  Not pretty, but it
      is much more likely to generate a unique name, and is reproducible
      (unlike, say, a random number).
      020ad8d1
  12. 14 4月, 2011 1 次提交
  13. 30 3月, 2011 1 次提交
    • N
      extend logging to record configuration-related changes · 343a27af
      Naoya Horiguchi 提交于
      Currently libvirt's default logging is limited and it is difficult to
      determine what was happening when a proglem occurred (especially on a
      machines where one don't know the detail.)  This patch helps to do that
      by making additional logging available for the following events:
      
        creating/defining/undefining domains
        creating/defining/undefining/starting/stopping networks
        creating/defining/undefining/starting/stopping storage pools
        creating/defining/undefining/starting/stopping storage volumes.
      
      * AUTHORS: add Naoya Horiguchi
      * src/network/bridge_driver.c src/qemu/qemu_driver.c
        src/storage/storage_driver.c: provide more VIR_INFO logging
      343a27af
  14. 25 3月, 2011 1 次提交
    • E
      maint: prohibit access(,X_OK) · 391c397e
      Eric Blake 提交于
      This simplifies several callers that were repeating checks already
      guaranteed by util.c, and makes other callers more robust to now
      reject directories.  remote_driver.c was over-strict - access(,R_OK)
      is only needed to execute a script file; a binary only needs
      access(,X_OK) (besides, it's unusual to see a file with x but not
      r permissions, whether script or binary).
      
      * cfg.mk (sc_prohibit_access_xok): New syntax-check rule.
      (exclude_file_name_regexp--sc_prohibit_access_xok): Exempt one use.
      * src/network/bridge_driver.c (networkStartRadvd): Fix offenders.
      * src/qemu/qemu_capabilities.c (qemuCapsProbeMachineTypes)
      (qemuCapsInitGuest, qemuCapsInit, qemuCapsExtractVersionInfo):
      Likewise.
      * src/remote/remote_driver.c (remoteFindDaemonPath): Likewise.
      * src/uml/uml_driver.c (umlStartVMDaemon): Likewise.
      * src/util/hooks.c (virHookCheck): Likewise.
      391c397e
  15. 19 3月, 2011 1 次提交
  16. 14 3月, 2011 1 次提交
    • L
      network driver: don't send default route to clients on isolated networks · 013427e6
      Laine Stump 提交于
      Normally dnsmasq will send a default route (the address of the host in
      the network definition) to any client requesting an address via
      DHCP. On an isolated network this makes no sense, as we have iptables
      to prevent any traffic going out via that interface, so anything sent
      that way would be dropped anyway.
      
      This extra/unusable default route becomes problematic if you have
      setup a guest with multiple network interfaces, with one connected to
      an isolated network and another that provides connectivity to the
      outside (example - one interface directly connecting to a physical
      interface via macvtap, with a second connected to an isolated network
      so that the host and guest can communicate (macvtap doesn't support
      guest<->host communication without an external switch that supports
      vepa, or reflecting all traffic back)). In this case, if the guest
      chooses the default route of the isolated network, the guest will not
      be able to get network traffic beyond the host.
      
      To prevent dnsmasq from sending a default route, you can tell it to
      send 0 bytes of data for the default route option (option number 3)
      with --dhcp-option=3 (normally the data to send for the option would
      follow the option number; no extra data means "don't send this option").
      
      I have checked on RHEL5 (a good representative of the oldest supported
      libvirt platforms) and its version of dnsmasq (2.45) does support
      --dhcp-option, so this shouldn't create any compatibility problems.
      013427e6
  17. 12 3月, 2011 3 次提交
    • L
      network driver: Use a separate dhcp leases file for each network · 13c00dde
      Laine Stump 提交于
      By default, all dnsmasq processes share the same leases file. libvirt
      also uses the --dhcp-lease-max option to control the maximum number of
      leases allowed. The problem is that libvirt puts in a number equal to
      the number of addresses in the range for the one network handled by a
      single instance of dnsmasq, but dnsmasq checks the total number of
      leases in the file (which could potentially contain many more).
      
      The solution is to tell each instance of dnsmasq to create and use its
      own leases file. (/var/lib/libvirt/network/<net-name>.leases).
      
      This file is created by dnsmasq when it starts, but not deleted when
      it exists. This is fine when the network is just being stopped, but if
      the leases file was left around when a network was undefined, we could
      end up with an ever-increasing number of dead files - instead, we
      explicitly unlink the leases file when a network is undefined.
      
      Note that Ubuntu carries a patch against an older version of libvirt for this:
      
      hhttps://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/713071
      ttp://bazaar.launchpad.net/~serge-hallyn/ubuntu/maverick/libvirt/bugall/revision/109
      
      I was certain I'd also seen discussion of this on libvir-list or
      libvirt-users, but couldn't find it.
      13c00dde
    • L
      network driver: Fix indentation from previous commit · e368e710
      Laine Stump 提交于
      The previous commit put a large portion of networkBuildDnsmasqArgv
      inside an if { } block. This readjusts the indentation.
      e368e710
    • L
      network driver: Start dnsmasq even if no dhcp ranges/hosts are specified. · 7892edc9
      Laine Stump 提交于
      This fixes a regression introduced in commit ad48df, and reported on
      the libvirt-users list:
      
        https://www.redhat.com/archives/libvirt-users/2011-March/msg00018.html
      
      The problem in that commit was that we began searching a list of ip
      address definitions (rather than just having one) to look for a dhcp
      range or static host; when we didn't find any, our pointer (ipdef) was
      left at NULL, and when ipdef was NULL, we returned without starting up
      dnsmasq.
      
      Previously dnsmasq was started even without any dhcp ranges or static
      entries, because it's still useful for DNS services.
      
      Another problem I noticed while investigating was that, if there are
      IPv6 addresses, but no IPv4 addresses of any kind, we would jump out
      at an ever higher level in the call chain.
      
      This patch does the following:
      
      1) networkBuildDnsmasqArgv() = all uses of ipdef are protected from
         NULL dereference. (this patch doesn't change indentation, to make
         review easier. The next patch will change just the
         indentation). ipdef is intended to point to the first IPv4 address
         with DHCP info (or the first IPv4 address if none of them have any
         dhcp info).
      
      2) networkStartDhcpDaemon() = if the loop looking for an ipdef with
         DHCP info comes up empty, we then grab the first IPv4 def from the
         list. Also, instead of returning if there are no IPv4 defs, we just
         return if there are no IP defs at all (either v4 or v6). This way a
         network that is IPv6-only will still get dnsmasq listening for DNS
         queries.
      
      3) in networkStartNetworkDaemon() - we will startup dhcp not just if there
         are any IPv4 addresses, but also if there are any IPv6 addresses.
      7892edc9
  18. 19 2月, 2011 1 次提交
  19. 18 2月, 2011 1 次提交
    • L
      Give each virtual network bridge its own fixed MAC address · 5754dbd5
      Laine Stump 提交于
      This fixes https://bugzilla.redhat.com/show_bug.cgi?id=609463
      
      The problem was that, since a bridge always acquires the MAC address
      of the connected interface with the numerically lowest MAC, as guests
      are started and stopped, it was possible for the MAC address to change
      over time, and this change in the network was being detected by
      Windows 7 (it sees the MAC of the default route change), so on each
      reboot it would bring up a dialog box asking about this "new network".
      
      The solution is to create a dummy tap interface with a MAC guaranteed
      to be lower than any guest interface's MAC, and attach that tap to the
      bridge as soon as it's created. Since all guest MAC addresses start
      with 0xFE, we can just generate a MAC with the standard "0x52, 0x54,
      0" prefix, and it's guaranteed to always win (physical interfaces are
      never connected to these bridges, so we don't need to worry about
      competing numerically with them).
      
      Note that the dummy tap is never set to IFF_UP state - that's not
      necessary in order for the bridge to take its MAC, and not setting it
      to UP eliminates the clutter of having an (eg) "virbr0-nic" displayed
      in the output of the ifconfig command.
      
      I chose to not auto-generate the MAC address in the network XML
      parser, as there are likely to be consumers of that API that don't
      need or want to have a MAC address associated with the
      bridge.
      
      Instead, in bridge_driver.c when the network is being defined, if
      there is no MAC, one is generated. To account for virtual network
      configs that already exist when upgrading from an older version of
      libvirt, I've added a %post script to the specfile that searches for
      all network definitions in both the config directory
      (/etc/libvirt/qemu/networks) and the state directory
      (/var/lib/libvirt/network) that are missing a mac address, generates a
      random address, and adds it to the config (and a matching address to
      the state file, if there is one).
      
      docs/formatnetwork.html.in: document <mac address.../>
      docs/schemas/network.rng: add nac address to schema
      libvirt.spec.in: %post script to update existing networks
      src/conf/network_conf.[ch]: parse and format <mac address.../>
      src/libvirt_private.syms: export a couple private symbols we need
      src/network/bridge_driver.c:
          auto-generate mac address when needed,
          create dummy interface if mac address is present.
      tests/networkxml2xmlin/isolated-network.xml
      tests/networkxml2xmlin/routed-network.xml
      tests/networkxml2xmlout/isolated-network.xml
      tests/networkxml2xmlout/routed-network.xml: add mac address to some tests
      5754dbd5
  20. 15 2月, 2011 1 次提交
  21. 01 2月, 2011 1 次提交
  22. 19 1月, 2011 2 次提交
  23. 06 1月, 2011 1 次提交
    • K
      bridge: Fix generation of dnsmasq's --dhcp-hostsfile option · a43c7338
      Kay Schubert 提交于
      I added a host definition to a network definition:
      
      <network>
        <name>Lokal</name>
        <uuid>2074f379-b82c-423f-9ada-305d8088daaa</uuid>
        <bridge name='virbr1' stp='on' delay='0' />
        <ip address='192.168.180.1' netmask='255.255.255.0'>
          <dhcp>
            <range start='192.168.180.128' end='192.168.180.254' />
            <host mac='23:74:00:03:42:02' name='somevm' ip='192.168.180.10' />
          </dhcp>
        </ip>
      </network>
      
      But due to the wrong if-statement the argument --dhcp-hostsfile doesn't get
      added to the dnsmasq command. The patch below fixes it for me.
      a43c7338
  24. 24 12月, 2010 8 次提交
    • L
      Run radvd for virtual networks with IPv6 addresses · 8090a568
      Laine Stump 提交于
      Running an instance of the router advertisement daemon (radvd) allows
      guests using the virtual network to automatically acquire an IPv6
      address and default route. Note that acquiring an address only works
      for networks with a prefix length of exactly 64 - radvd is still run
      in other circumstances, and still advertises routes, but autoconf will
      not work because it requires exactly 64 bits of address info from the
      network prefix.
      
      This patch avoids a race condition with the pidfile by manually
      daemonizing radvd rather than allowing it to daemonize itself, then
      creating our own pidfile (in addition to radvd's own file, which is
      unnecessary, but there is no way to tell radvd to not create it). This
      is accomplished by exec'ing it with "--debug 1" in the commandline,
      and using virCommand's features to fork, create a pidfile, and detach
      from the newly forked process.
      8090a568
    • L
      Turn on IPv6 support in the bridge_driver.c virtual network driver · 6ccce752
      Laine Stump 提交于
      At this point everything is already in place to make IPv6 happen, we just
      need to add a few rules, remove some checks for IPv4-only, and document
      the changes to the XML on the website.
      6ccce752
    • L
      Update iptables.c to also support ip6tables. · 537e65e7
      Laine Stump 提交于
      All of the iptables functions eventually call down to a single
      bottom-level function, and fortunately, ip6tables syntax (for all the
      args that we use) is identical to iptables format (except the
      addresses), so all we need to do is:
      
      1) Get an address family down to the lowest level function in each
         case, either implied through an address, or explicitly when no
         address is in the parameter list, and
      
      2) At the lowest level, just decide whether to call "iptables" or
         "ip6tables" based on the family.
      
      The location of the ip6tables binary is determined at build time by
      autoconf. If a particular target system happens to not have ip6tables
      installed, any attempts to run it will generate an error, but that
      won't happen unless someone tries to define an IPv6 address for a
      network. This is identical behavior to IPv4 addresses and iptables.
      537e65e7
    • L
      Support multiple IP addresses on one network in bridge_driver.c · ad48dfa1
      Laine Stump 提交于
      This patch reorganizes the code in bridge_driver.c to account for the
      concept of a single network with multiple IP addresses, without adding
      in the extra variable of IPv6. A small bit of code has been
      temporarily added that checks all given addresses to verify they are
      IPv4 - this will be removed when full IPv6 support is turned on.
      ad48dfa1
    • L
      Change virtual network XML parsing/formatting to support IPv6 · a950dd2a
      Laine Stump 提交于
      This commit adds support for IPv6 parsing and formatting to the
      virtual network XML parser, including moving around data definitions
      to allow for multiple <ip> elements on a single network, but only
      changes the consumers of this API to accommodate for the changes in
      API/structure, not to add any actual IPv6 functionality. That will
      come in a later patch - this patch attempts to maintain the same final
      functionality in both drivers that use the network XML parser - vbox
      and "bridge" (the Linux bridge-based driver used by the qemu
      hypervisor driver).
      
      * src/libvirt_private.syms: Add new private API functions.
      * src/conf/network_conf.[ch]: Change C data structure and
        parsing/formatting.
      * src/network/bridge_driver.c: Update to use new parser/formatter.
      * src/vbox/vbox_tmpl.c: update to use new parser/formatter
      * docs/schemas/network.rng: changes to the schema -
        * there can now be more than one <ip> element.
        * ip address is now an ip-addr (ipv4 or ipv6) rather than ipv4-addr
        * new optional "prefix" attribute that can be used in place of "netmask"
        * new optional "family" attribute - "ipv4" or "ipv6"
          (will default to ipv4)
        * define data types for the above
      * tests/networkxml2xml(in|out)/nat-network.xml: add multiple <ip> elements
        (including IPv6) to a single network definition to verify they are being
        correctly parsed and formatted.
      a950dd2a
    • L
      Replace brSetInetAddress/brSetInetNetmask with brAddInetAddress · 20718b8b
      Laine Stump 提交于
      brSetInetAddress can only set a single IP address on the bridge, and
      uses a method (ioctl(SIOCSETIFADDR)) that only works for IPv4. Replace
      it and brSetInetNetmask with a single function that uses the external
      "ip addr add" command to add an address/prefix to the interface - this
      supports IPv6, and allows adding multiple addresses to the interface.
      
      Although it isn't currently used in the code, we also add a
      brDelInetAddress for completeness' sake.
      
      Also, while we're modifying bridge.c, we change brSetForwardDelay and
      brSetEnableSTP to use the new virCommand API rather than the
      deprecated virRun, and also log an error message in bridge_driver.c if
      either of those fail (previously the failure would be completely
      silent).
      20718b8b
    • L
      Pass prefix rather than netmask into iptables functions · b23d417c
      Laine Stump 提交于
      IPv6 will use prefix exclusively, and IPv4 will also optionally be
      able to use it, and the iptables functions really need a prefix
      anyway, so use the new virNetworkDefPrefix() function to send prefixes
      into iptables functions instead of netmasks.
      
      Also, in a couple places where a netmask is actually needed, use the
      new private API function for it rather than getting it directly. This
      will allow for cases where no netmask or prefix is specified (it
      returns the default for the current class of network.)
      b23d417c
    • L
      Consistently return 0 on success, -1 on failure in bridge_driver.c · 6e3e6db1
      Laine Stump 提交于
      Some functions in this file were returning 1 on success and 0 on
      failure, and others were returning 0 on success and -1 on
      failure. Switch them all to return the libvirt-preferred 0/-1.
      6e3e6db1