1. 08 4月, 2013 5 次提交
    • D
      Copy struct inotify_event entries to avoid alignment problems · 7e6aabc6
      Daniel P. Berrange 提交于
      When reading the inotify FD, we get back a sequence of
      struct inotify_event, each with variable length data following.
      It is not safe to simply cast from the char *buf to the
      struct inotify_event struct since this may violate data
      alignment rules. Thus we must copy from the char *buf
      into the struct inotify_event instance before accessing
      the data.
      
      uml/uml_driver.c: In function 'umlInotifyEvent':
      uml/uml_driver.c:327:13: warning: cast increases required alignment of target type [-Wcast-align]
               e = (struct inotify_event *)tmp;
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      7e6aabc6
    • D
      Use VIR_ALLOC_VAR instead of VIR_ALLOC_N for creating virObject · c4f9edf1
      Daniel P. Berrange 提交于
      The current way virObject instances are allocated using
      VIR_ALLOC_N causes alignment warnings
      
      util/virobject.c: In function 'virObjectNew':
      util/virobject.c:195:11: error: cast increases required alignment of target type [-Werror=cast-align]
      
      Changing to use VIR_ALLOC_VAR will avoid the need todo
      the casts entirely.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c4f9edf1
    • D
      Avoid casts between unsigned char * and struct nlmsghdr · e95de74d
      Daniel P. Berrange 提交于
      The virNetlinkCommand() method takes an 'unsigned char **'
      parameter to be filled with the received netlink message.
      The callers then immediately cast this to 'struct nlmsghdr',
      triggering (bogus) warnings about increasing alignment
      requirements
      
      util/virnetdev.c: In function 'virNetDevLinkDump':
      util/virnetdev.c:1300:12: warning: cast increases required alignment of target type [-Wcast-align]
           resp = (struct nlmsghdr *)*recvbuf;
                  ^
      util/virnetdev.c: In function 'virNetDevSetVfConfig':
      util/virnetdev.c:1429:12: warning: cast increases required alignment of target type [-Wcast-align]
           resp = (struct nlmsghdr *)recvbuf;
      
      Since all callers cast to 'struct nlmsghdr' we can avoid
      the warning problem entirely by simply changing the
      signature of virNetlinkCommand to return a 'struct nlmsghdr **'
      instead of 'unsigned char **'. The way we do the cast inside
      virNetlinkCommand does not have any alignment issues.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e95de74d
    • D
      Rewrite keycode map to avoid a struct · d27efd8e
      Daniel P. Berrange 提交于
      Playing games with field offsets in a struct causes all sorts
      of alignment warnings on ARM platforms
      
      util/virkeycode.c: In function '__virKeycodeValueFromString':
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:91:28: note: in expansion of macro 'getfield'
               const char *name = getfield(virKeycodes + i, const char *, name_offset);
                                  ^
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:94:20: note: in expansion of macro 'getfield'
                   return getfield(virKeycodes + i, unsigned short, code_offset);
                          ^
      util/virkeycode.c: In function '__virKeycodeValueTranslate':
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:127:13: note: in expansion of macro 'getfield'
               if (getfield(virKeycodes + i, unsigned short, from_offset) == key_value)
                   ^
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:128:20: note: in expansion of macro 'getfield'
                   return getfield(virKeycodes + i, unsigned short, to_offset);
      
      There is no compelling reason to use a struct for the keycode
      tables. It can easily just use an array of arrays instead,
      avoiding all alignment problems
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      d27efd8e
    • D
      Add a test suite for keycode mapping functions · 15d8511b
      Daniel P. Berrange 提交于
      Validate that translations between different keycode sets
      are functioning.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      15d8511b
  2. 06 4月, 2013 5 次提交
    • O
      qemu: Error out if the bitmap for pinning is all clear · fd1432c7
      Osier Yang 提交于
      For both "live" and "config" changes of vcpupin and emulatorpin, an
      all clear bitmap doesn't make sense, and it can just cause corruptions.
      E.g (similar for emulatorpin).
      
      % virsh vcpupin hame 0 8,^8 --config
      
      % virsh vcpupin hame
      VCPU: CPU Affinity
      ----------------------------------
         0:
         1: 0-63
         2: 0-63
         3: 0-63
      
      % virsh dumpxml hame | grep cpuset
          <vcpupin vcpu='0' cpuset=''/>
      
      % virsh start hame
      error: Failed to start domain hame
      error: An error occurred, but the cause is unknown
      fd1432c7
    • O
      1acfc171
    • O
      qemu: Support multiple queue virtio-scsi · d4bf0a93
      Osier Yang 提交于
      This introduce a new attribute "num_queues" (same with the good name
      QEMU uses) for virtio-scsi controller. An example of the XML:
      
      <controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/>
      
      The corresponding QEMU command line:
      
      -device virtio-scsi-pci,id=scsi0,num_queues=8,bus=pci.0,addr=0x3 \
      d4bf0a93
    • E
      build: check correct protocol.o file · 5899e09e
      Eric Blake 提交于
      By default, libtool builds two .o files for every .lo rule:
      src/foo.o - static builds
      src/.libs/foo.o - shared library builds
      
      But since commit ad42b34b disabled static builds, src/foo.o is
      no longer built by default.  On a fresh checkout, this means our
      protocol check rules using pdwtags were testing a missing file,
      and thanks to a lousy behavior of pdwtags happily giving no output
      and 0 exit status (http://bugzilla.redhat.com/949034), we were
      merely claiming that "dwarves is too old" and skipping the test.
      
      However, if you swap between branches and do incremental builds,
      such as building v0.10.2-maint and then switching back to master,
      you end up with src/foo.o being leftover from its 0.10.2 state,
      and then 'make check' fails because the .o file does not match
      the protocol-structs file due to API additions in the meantime.
      
      A simpler fix would be to always look in .libs for the .o to
      be parsed; but since it is possible to pass ./configure options
      to tell libtool to do a static-only build with no shared .o,
      I went with the approach of finding the newest of the two files,
      whenever both exist.
      
      * src/Makefile.am (PDWTAGS): Ensure we test just-built file.
      5899e09e
    • E
      build: use proper pod for nested bulleted VIRSH_DEBUG list · 00d69b4a
      Eric Blake 提交于
      Newer pod (hello rawhide) complains if you attempt to mix bullets
      and non-bullets in the same list:
      
      virsh.pod around line 3177: Expected text after =item, not a bullet
      
      As our intent was to nest an inner list, we make that explicit to
      keep pod happy.
      
      * tools/virsh.pod (ENVIRONMENT): Use correct pod syntax.
      00d69b4a
  3. 05 4月, 2013 21 次提交
    • P
      qemu: Remove maximum cpu limit when setting processor count using the API · ce65b435
      Peter Krempa 提交于
      When setting processor count for a domain using the API libvirt enforced
      a maximum processor count, while it isn't enforced when taking the XML path.
      
      This patch removes the check to match the XML.
      ce65b435
    • D
      Don't create dirs in cgroup controllers we don't want to use · 56f27b3b
      Daniel P. Berrange 提交于
      Currently when getting an instance of virCgroupPtr we will
      create the path in all cgroup controllers. Only at the virt
      driver layer are we attempting to filter controllers. This
      is bad because the mere act of creating the dirs in the
      controllers can have a functional impact on the kernel,
      particularly for performance.
      
      Update the virCgroupForDriver() method to accept a bitmask
      of controllers to use. Only create dirs in the controllers
      that are requested. When creating cgroups for domains,
      respect the active controller list from the parent cgroup
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      56f27b3b
    • D
      Rename virCgroupGetAppRoot to virCgroupForSelf · 804a809a
      Daniel P. Berrange 提交于
      The virCgroupGetAppRoot is not clear in its meaning. Change
      to virCgroupForSelf to highlight that this returns the
      cgroup config for the caller's process
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      804a809a
    • D
      Ensure LD_PRELOAD exists before running test case · b1d3154a
      Daniel P. Berrange 提交于
      The linker will ignore LD_PRELOAD libraries which do not
      exist, just printing a warning message. This is not helpful
      for the test suite which will be utterly fubar without the
      preload library present. Add an explicit test for existence
      of the library to protect against this
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b1d3154a
    • D
      Refactor RNG schema for resource tuning · 8ef2b2c5
      Daniel P. Berrange 提交于
      Split the "resource" define out into multiple smaller
      defines, one for each type of resource tuning parameter.
      This makes the schema a bit clearer to read
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      8ef2b2c5
    • P
      rpc: Fix connection close callback race condition and memory corruption/crash · 8ad126e6
      Peter Krempa 提交于
      The last Viktor's effort to fix the race and memory corruption unfortunately
      wasn't complete in the case the close callback was not registered in an
      connection. At that time, the trail of event's that I'll describe later could
      still happen and corrupt the memory or cause a crash of the client (including
      the daemon in case of a p2p migration).
      
      Consider the following prerequisities and trail of events:
      Let's have a remote connection to a hypervisor that doesn't have a close
      callback registered and the client is using the event loop. The crash happens in
      cooperation of 2 threads. Thread E is the event loop and thread W is the worker
      that does some stuff. R denotes the remote client.
      
      1.) W - The client finishes everything and sheds the last reference on the client
      2.) W - The virObject stuff invokes virConnectDispose that invokes doRemoteClose
      3.) W - the remote close method invokes the REMOTE_PROC_CLOSE RPC method.
      4.) W - The thread is preempted at this point.
      5.) R - The remote side receives the close and closes the socket.
      6.) E - poll() wakes up due to the closed socket and invokes the close callback
      7.) E - The event loop is preempted right before remoteClientCloseFunc is called
      8.) W - The worker now finishes, and frees the conn object.
      9.) E - The remoteClientCloseFunc accesses the now-freed conn object in the
              attempt to retrieve pointer for the real close callback.
      10.) Kaboom, corrupted memory/segfault.
      
      This patch tries to fix this by introducing a new object that survives the
      freeing of the connection object. We can't increase the reference count on the
      connection object itself or the connection would never be closed, as the
      connection is closed only when the reference count reaches zero.
      
      The new object - virConnectCloseCallbackData - is a lockable object that keeps
      the pointers to the real user registered callback and ensures that the
      connection callback is either not called if the connection was already freed or
      that the connection isn't freed while this is being called.
      8ad126e6
    • P
      virsh: Register and unregister the close callback also in cmdConnect · 69ab0756
      Peter Krempa 提交于
      This patch improves the error message after disconnecting from the
      hypervisor and adds the close callback operations required not to leak
      the callback reference.
      69ab0756
    • P
      virsh: Move cmdConnect from virsh-host.c to virsh.c · ca9e73eb
      Peter Krempa 提交于
      The function is used to establish connection so it should be in the main
      virsh file. This movement also enables further improvements done in next
      patches.
      
      Note that the "connect" command has moved from the host section of virsh to the
      main section. It is now listed by 'virsh help virsh' instead of 'virsh help
      host'.
      ca9e73eb
    • V
      virsh: Unregister the connection close notifier upon termination · e964ba27
      Viktor Mihajlovski 提交于
      Before closing the connection we unregister the close callback
      to prevent a reference leak.
      
      Further, the messages on virConnectClose != 0 are a bit more specific
      now.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      e964ba27
    • V
      libvirt: Increase connection reference count for callbacks · 03a43efa
      Viktor Mihajlovski 提交于
      By adjusting the reference count of the connection object we
      prevent races between callback function and virConnectClose.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      03a43efa
    • P
      virCaps: get rid of defaultConsoleTargetType callback · 482e5f15
      Peter Krempa 提交于
      This patch refactors various places to allow removing of the
      defaultConsoleTargetType callback from the virCaps structure.
      
      A new console character device target type is introduced -
      VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was
      specified in the XML. This type is at the end converted to the standard
      VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are
      different from this default have to be processed separately in the
      device post parse callback.
      482e5f15
    • P
      virCaps: get rid of macPrefix field · 46becc18
      Peter Krempa 提交于
      Use the virDomainXMLConf structure to hold this data and tweak the code
      to avoid semantic change.
      
      Without configuration the KVM mac prefix is used by default. I chose it
      as it's in the privately administered segment so it should be usable for
      any purposes.
      46becc18
    • P
      virCaps: get rid of hasWideScsiBus · 8960d656
      Peter Krempa 提交于
      Use the virDomainXMLConf structure to hold this data.
      8960d656
    • P
      virCaps: get rid of defaultDiskDriverType · b2990849
      Peter Krempa 提交于
      Use the qemu specific callback to fill this data in the qemu driver as
      it's the only place where it was used and fix tests as the qemu test
      capability object didn't configure the defaults for the tests.
      b2990849
    • P
      virCaps: get rid of emulatorRequired · b5def001
      Peter Krempa 提交于
      This patch removes the emulatorRequired field and associated
      infrastructure from the virCaps object. Instead the driver specific
      callbacks are used as this field isn't enforced by all drivers.
      
      This patch implements the appropriate callbacks in the qemu and lxc
      driver and moves to check to that location.
      b5def001
    • P
      virCaps: get rid of defaultDiskDriverName · 9ea249e7
      Peter Krempa 提交于
      This patch removes the defaultDiskDriverName from the virCaps
      structure. This particular default value is used only in the qemu driver
      so this patch uses the recently added callback to fill the driver name
      if it's needed instead of propagating it through virCaps.
      9ea249e7
    • P
      virCaps: get rid of "defaultInitPath" value in the virCaps struct · 4750c848
      Peter Krempa 提交于
      This gets rid of the parameter in favor of using the new callback
      infrastructure to do the same stuff.
      
      This patch implements the domain adjustment callback in the openVZ
      driver and moves the check from the parser to a new validation method in
      the callback infrastructure.
      4750c848
    • P
      qemu: Record the default NIC model in the domain XML · a68d6726
      Peter Krempa 提交于
      This patch implements the devices post parse callback and uses it to fill
      the default qemu network card model into the XML if none is specified.
      
      Libvirt assumes that the network card model for qemu is the "rtl8139".
      Record this in the XML using the new callback to avoid user
      confusion.
      a68d6726
    • P
      conf callback: Rearrange function parameters · ad0d10b2
      Peter Krempa 提交于
      Move the xmlopt and caps arguments to the end of the argument list.
      ad0d10b2
    • P
      conf: Add post XML parse callbacks and prepare for cleaning of virCaps · 43b99fc4
      Peter Krempa 提交于
      This patch adds instrumentation that will allow hypervisor drivers to
      fill and validate domain and device definitions after parsed by the XML
      parser.
      
      With this patch, after the XML is parsed, a callback to the driver is
      issued requesting to fill and validate driver specific details of the
      configuration. This allows to use sensible defaults and checks on a per
      driver basis at the time the XML is parsed.
      
      Two callback pointers are stored in the new virDomainXMLConf object:
      * virDomainDeviceDefPostParseCallback (devicesPostParseCallback)
        - called for a single device parsed and for every single device in a
          domain config. A virDomainDeviceDefPtr is passed along with the
          domain definition and virCaps.
      
      * virDomainDefPostParseCallback, (domainPostParseCallback)
        - A callback that is meant to process the domain config after it's
        parsed.  A virDomainDefPtr is passed along with virCaps.
      
      Both types of callbacks support arbitrary opaque data passed for the
      callback functions.
      
      Errors may be reported in those callbacks resulting in a XML parsing
      failure.
      43b99fc4
    • P
      maint: Rename xmlconf to xmlopt and virDomainXMLConfig to virDomainXMLOption · e84b1931
      Peter Krempa 提交于
      This patch is the result of running:
      
      for i in $(git ls-files | grep -v html | grep -v \.po$ ); do
        sed -i -e "s/virDomainXMLConf/virDomainXMLOption/g" -e "s/xmlconf/xmlopt/g" $i
      done
      
      and a few manual tweaks.
      e84b1931
  4. 04 4月, 2013 9 次提交