112 Commits

Author SHA1 Message Date
Wido den Hollander
2a5f37c1b1
CLOUDSTACK-8715: Add channel to Instances for Qemu Guest Agent
This commit adds a additional VirtIO channel with the name
'org.qemu.guest_agent.0' to all Instances.

With the Qemu Guest Agent the Hypervisor gains more control over the Instance if
these tools are present inside the Instance, for example:

* Power control
* Flushing filesystems
* Fetching Network information

In the future this should allow safer snapshots on KVM since we can instruct the
Instance to flush the filesystems prior to snapshotting the disk.

More information: http://wiki.qemu.org/Features/QAPI/GuestAgent

Keep in mind that on Ubuntu AppArmor still needs to be disabled since the default
AppArmor profile doesn't allow libvirt to write into /var/lib/libvirt/qemu

This commit does not add any communication methods through API-calls, it merely
adds the channel to the Instances and installs the Guest Agent in the SSVMs.

With the addition of the Qemu Guest Agent channel a second channel appears in /dev
on a SSVM as a VirtIO port.

The order in which the ports are defined in the XML matters for the naming inside
the SSVM VM and by not relying on /dev/vportXX but looking for a static name the
SSVM still boots properly if the order in the XML definition is changed.

A SSVM with both ports attached will have something like this:

  root@v-215-VM:~# ls -l /dev/virtio-ports
  total 0
  lrwxrwxrwx 1 root root 11 May 13 21:41 org.qemu.guest_agent.0 -> ../vport0p2
  lrwxrwxrwx 1 root root 11 May 13 21:41 v-215-VM.vport -> ../vport0p1
  root@v-215-VM:~# ls -l /dev/vport*
  crw------- 1 root root 251, 1 May 13 21:41 /dev/vport0p1
  crw------- 1 root root 251, 2 May 13 21:41 /dev/vport0p2
  root@v-215-VM:~#

In this case the SSVM port points to /dev/vport0p1, but if the order in the XML
is different it might point to /dev/vport0p2

By looking for a portname with a pre-defined pattern in /dev/virtio-ports we
do not rely on the order in the XML definition.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2016-11-23 16:01:08 +01:00
Rohit Yadav
0642a6982f
Merge branch '4.9' 2016-11-23 14:22:15 +05:30
Rohit Yadav
55b918076f
Merge branch '4.8' into 4.9 2016-11-23 13:50:15 +05:30
Rohit Yadav
ff616e700b Merge pull request #1745 from shapeblue/CLOUDSTACK-9503
CLOUDSTACK-9503: Increased the VR script timeout. Most of the changes are about converting int/long time values to joda Duration.

* pr/1745:
  CLOUDSTACK-9503: Increased the VR script timeout. Most of the changes are about converting int/long time values to joda Duration.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2016-11-23 13:41:52 +05:30
Abhinandan Prateek
83b5a8b2b2 CLOUDSTACK-9503: Increased the VR script timeout. Most of the changes are about converting int/long time values to joda Duration. 2016-11-01 16:14:23 +05:30
Wido den Hollander
0beb41b6e7 CLOUDSTACK-9395: Add Virtio RNG device to Instances when configured
By adding a Random Number Generator device to Instances we can prevent
entropy starvation inside guest.

The default source is /dev/random on the host, but this can be configured
to another source when present, for example a hardware RNG.

When enabled it will add the following to the Instance's XML definition:

  <rng model='virtio'>
    <rate period='1000' bytes='2048' />
    <backend model='random'>/dev/random</backend>
  </rng>

If the Instance has the proper support, which most modern distributions have,
it will have a /dev/hwrng device which it can use for gathering entropy.

More information: https://libvirt.org/formatdomain.html#elementsRng
2016-10-04 12:44:55 +02:00
weingartner
866ac7b6e1 Fixed issues from CLOUDSTACK-8800 that were introduced in PR 780
It was worked around some possible runtime exceptions introduced by the
changes that were added by the PR 780. Basically, the points in which a
null pointer exception could happen, we added safety checks to avoid
them. It was create a specific method do that, all together test cases
were created for this newly method that was added.
2016-05-03 14:05:18 -03:00
Maneesha.P
7ad3c5e834 CLOUDSTACK-8800 : Improved the listVirtualMachines API call to include memory utilization information for a VM for xenserver,kvm and for vmware. 2016-04-29 14:06:49 -03:00
Will Stevens
ad61d49d87 Merge release branch 4.8 to master
* 4.8:
  CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe way
2016-04-28 15:57:43 -04:00
Will Stevens
43ab44dd58 Merge release branch 4.7 to 4.8
* 4.7:
  CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe way
2016-04-28 15:56:48 -04:00
Will Stevens
f530a4c63a Merge pull request #1200 from koushik-das/CLOUDSTACK-9130
CLOUDSTACK-9130: Make RebootCommand similar to start/stop/migrate agent commands w.r.t. "execute in sequence" flag

RebootCommand now behaves in the same way as start/stop/migrate agent commands w.r.t. to sequential/parallel execution.

* pr/1200:
  CLOUDSTACK-9130: Make RebootCommand similar to start/stop/migrate agent commands w.r.t. "execute in sequence" flag RebootCommand now behaves in the same way as start/stop/migrate agent commands w.r.t. to sequential/parallel execution.

Signed-off-by: Will Stevens <williamstevens@gmail.com>
2016-04-21 16:35:27 -04:00
Koushik Das
d1def0a730 Merge pull request #1287 from DaanHoogland/securityrules-cleanup
SecurityGroupRulesCmd code cleanupWrote a test and cleaned some duplicate code with the objective to evaluate the jenkins pull request process at builds.a.o
worthwhile to keep, IMHO.

* pr/1287:
  SecurityGroupRulesCmd code cleanup review comments handled
  deal with PMD warnings
  code cleanup
  security rules test
  remove autogenerated pydev files

Signed-off-by: Koushik Das <koushik@apache.org>
2016-04-11 21:49:57 +05:30
Will Stevens
c48b6c33c0 Revert "Merge pull request #780 from maneesha-p/pull-19" due code quality issues and lack of CI results.
This reverts commit dc0ba6bd1a774d3ff4bc4a4dcc00e1434ab1f6e3, reversing
changes made to 63f58dd5785ff2515b087d907bdf686347c75727.
2016-03-21 17:38:04 -04:00
Maneesha.P
732a85295d CLOUDSTACK-8800 : Improved the listVirtualMachines API call to include memory utilization information for a VM for xenserver,kvm and for vmware. 2016-03-16 16:13:10 +05:30
Daan Hoogland
8a6afa6d9f CLOUDSTACK-9142 Migrate VM changes xmlDesc in a safe way 2016-01-21 21:32:35 +01:00
Daan Hoogland
d39182f9d4 deal with PMD warnings 2015-12-26 09:02:30 +01:00
Wido den Hollander
268b9b31e7 test: Fix Libvirt test so that it works on Windows 2015-12-14 11:33:47 +01:00
Koushik Das
5b3ffeb6cd CLOUDSTACK-9130: Make RebootCommand similar to start/stop/migrate agent commands w.r.t. "execute in sequence" flag
RebootCommand now behaves in the same way as start/stop/migrate agent commands w.r.t. to sequential/parallel execution.
2015-12-09 15:19:10 +05:30
Daan Hoogland
638f1cf091 Merge pull request #1049 from DaanHoogland/CLOUDSTACK-9047
CLOUDSTACK-9047 rename enumsmake enums adhere to best practice naming conventions

* pr/1049:
  CLOUDSTACK-9046 rename enums to adhere to naming conventions
  CLOUDSTACK-9046 renamed enums in kvm plugin
  CLOUDSTACK-9047 use 'State's only with context   there are more types called 'State'   (or to be called so but now 'state')   So remove imports and prepend their enclosing class/context to them.

Signed-off-by: Daan Hoogland <daan@onecht.net>
2015-12-06 20:17:04 +01:00
Josh Harshman
b6c900fdde CLOUDSTACK-9004: Add features to HyperVEnlightenmentFeatureDef
Add function to set vapic, spinlock and retries
Add function to get retry value
Modify toString to output appropriate XML for spinlock value if set

CLOUDSTACK-9004: Add features to HyperVEnlightenmentFeatureDef

Refactored set methods to get rid of code duplication.
Modified unit tests accordingly
2015-12-03 16:49:00 -08:00
Remi Bergsma
4ecfc29267 Merge release branch 4.6 to master
* 4.6:
  Use version for RC branch name instead of branch
  make sure all files are updates with new version
  Update L10N resource files with 4.6 strings from Transifex (20151129)
  Fix secondary storage not working with swift
  CLOUDSTACK-9083: Add disk serial to kvm virt xml
2015-11-30 22:30:52 +01:00
Rohit Yadav
12c395b560 CLOUDSTACK-9083: Add disk serial to kvm virt xml
Adds disk serial ids based on volume uuids to the virt xml. This may be useful
for appliances/software that needs some serial ids on the VM disks. This does not
impact existing/running VMs, the vm virt xmls will be updates for running VMs
the next time they are stopped/started.

For testing, disk serial (of debian based systemvm) in the virt xml matched that
in /sys/devices/pci0000:00:0000:00:07.0/virtio4/block/vda/serial.

We currently don't support scsi-blcok devices for which serial is not supported,
for this we've added a DeviceType (LUN) which may be used in future and a check
to not add the serial to the xml if disk type is LUN.
Refer: https://libvirt.org/formatdomain.html#elementsDisks

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-11-25 14:58:42 +05:30
Daan Hoogland
08eb96776a CLOUDSTACK-9037 patterns can be more elaborate then prefixes. 2015-11-23 11:48:44 +01:00
Daan Hoogland
962d4b4afe CLOUDSTACK-9046 renamed enums in kvm plugin 2015-11-16 13:41:14 +00:00
Remi Bergsma
0b4cc5de87 Merge pull request #986 from wido/kvm-libvirt-unittests
Add Unit Tests for Libvirt/KVM storage codeThese classes were not covered by Unit Tests and this commit
adds some tests for their basic functionality.

* pr/986:
  Add Unit Tests for Libvirt/KVM storage code

Signed-off-by: Remi Bergsma <github@remi.nl>
2015-11-02 17:53:31 +01:00
Wido den Hollander
602231132d kvm: Add UnitTests for LibvirtUtilitiesHelper
These were lacking, but this helper is used in various places
inside the KVM code.

Some simple tests to verify the helper is doing what we expect it
to do.
2015-10-30 12:34:00 +01:00
Wido den Hollander
7568f2123c Add Unit Tests for Libvirt/KVM storage code
These classes were not covered by Unit Tests and this commit
adds some tests for their basic functionality.
2015-10-27 13:21:28 +01:00
Daan Hoogland
5a134a6fe6 unit test for interface patterns in libvirt compute resource 2015-10-24 00:57:01 +02:00
Mike Tutkowski
c5a0d5e01c Support live migration on older version of Libvirt 2015-08-31 22:06:51 -06:00
Koushik Das
e1db6efc74 Removed unused agent command AttachVolumeCommand and corresponding answer AttachVolumeAnswer 2015-08-26 09:50:23 +05:30
Rohit Yadav
869a83f8f8 plugins: fix test case, interface usage and checkstyle import issue
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 12:23:50 +05:30
Daan Hoogland
10853bfa8a adhere to naming conventions for enums
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>
2015-07-14 11:50:39 +02:00
wilderrodrigues
e348e76eee CLOUDSTACK-8607 - Improving unit tests
- Adding more unit tests as suggested by Daan and Rajani.
   - Mocking SshHelper and the Script classes, used by Citrix and Libvirt resources respectively.
2015-07-06 14:58:17 +02:00
wilderrodrigues
47c7a1083f CLOUDSTACK-8607 - Adding update_host_passwd.sh script
- Modifying the LibvirtUpdateHostPasswordCommandWrapper in order to execute the script on the host
   - Adding the script path to LibvirtComputingResource
   - Adding the host IP address as an instance variable on UpdateHostPasswordCommand
   - Improving the Unit Test (LibvirtComputingResourceTest) to get it covering the new code
2015-07-02 14:54:51 +02:00
wilderrodrigues
527d6ee77b Making possible to update KVM hosts password in the database via the API
- Make sure the doUpdateHostPassword() method returns the result from the answer, not always true
   - Added the LibvirtUpdateHostPasswordCommandWrapper class, which will handle the changes in the KVM agent
     That's will be further implemented in the future. The command will avoid the agent to complain about Unsupported command
   - Added a test to make sure the current implementation of the comment works
     - If changes in the future, it will also require changes. In that way, we make sure nobody will break it

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes #527
2015-06-29 09:59:12 +02:00
wilderrodrigues
607a63b12d Mocking the Connect object used in the LibvirtMigrateCommandWrapper
When executing the tests in an environment where Libvirt is also installed, it
caused errors.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #342
2015-06-01 21:11:25 +02:00
wilderrodrigues
b267c5fc5a Replacing real IPs by 127.0.0.1. - It was causing problems in some environments - The Ips should have been removed in a previous commit, but some of them were missed
Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes #325
2015-05-29 11:25:40 +02:00
Rohit Yadav
cde6ef94b8 CLOUDSTACK-8247: Pull average Cpu util report between polling
Pull average Cpu util report between polling intervals instead of since boot
instead of using values since uptime

(cherry picked from commit 04176eaf171b46638be99b2f675aa2f09e99e1b8)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

This closes #297
2015-05-25 15:52:00 +02:00
Rohit Yadav
c37060a1ff CLOUDSTACK-8338: Fix hypervisor stats reporting for KVM on EL7
EL7 has a different output to 'free', use /proc/meminfo instead of a tool to be
more consistent across distros

(cherry picked from commit 212a05a345aa19cd2597b7ff5d6a1da7b35b9fc1)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
2015-05-22 12:10:54 +01:00
wilderrodrigues
982a0235a0 CLOUDSTACK-8486
Removing real IPs from the tests because they cause a long running time for LibvirtComputingResourceTest
    - In a local machine it takes 1.977s, but in a KVM test environment it's taking 257.879 sec
2015-05-20 14:52:08 +02:00
wilderrodrigues
ab7473eea0 Changing the JUnit runner in order to avoid problems with Java 8 - All tests passed using different approaches - Maven with parameters: -Dmaven.compiler.source=1.8 -Dmaven.compiler.target=1.8 - Maven without parameters
All builds were executed using javac 1.8.0_31

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #266
2015-05-20 09:53:46 +01:00
wilderrodrigues
0cdb4b6108 Fixing the testGetHostStatsCommand test under LibvirtComputingResourceTest. - Removed the expected value from the Test annotation - Mocking the bash path in order to avoid environment/OS issues
Fixing typo on LibvirtRequestWrapper
  - Replace linbvirtCommands by libvirtCommands on LibvirtRequestWrapper

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #255
2015-05-18 20:07:02 +02:00
wilderrodrigues
f575206ad4 Fixing testModifySshKeysCommand in the LibvirtComputingResourceTest class
- The test was okay, but when running in an environment where a /root/.ssh/id_rsa existed, it would return true then fail
  - We now mock the calls to methods that return the key paths, instead of relying in the static variables
2015-05-08 19:53:03 +02:00
wilderrodrigues
74ad48db55 Refactoring the LibvirtComputingResource
- Adding LibvirtStartCommandWrapper
  - 8 unit tests added
  - KVM hypervisor plugin with 23.2% coverage
2015-05-06 19:24:16 +02:00
wilderrodrigues
09656ca84e Refactoring the LibvirtComputingResource
- Adding LibvirtNetworkElementCommandWrapper and LibvirtStorageSubSystemCommandWrapper
  - 2 unit tests added
  - KVM hypervisor plugin with 22.2% coverage

I also refactored the StorageSubSystemCommand interface into an abstract class
  - Remove the pseudo-multiple-inheritance implementation
    - The StorageSubSystemCommand was an interface, not related to the Command class
      and its implementation were extending the Command class anyway. The whole structure is better now.
2015-05-06 19:24:16 +02:00
wilderrodrigues
08106e34d0 Refactoring the LibvirtComputingResource
- Adding LibvirtResizeVolumeCommandWrapper
  - 5 unit tests added
  - KVM hypervisor plugin with 22.1% coverage
2015-05-06 19:24:15 +02:00
wilderrodrigues
ae505e7bef Refactoring the LibvirtComputingResource
- Addin LibvirtPvlanSetupCommandWrapper
  - 6 unit tests added
  - KVM hypervisor plugin with 21% coverage

From the 6 tests added, 2 were extra tests to increase the coverage of the LibvirtStopCommandWrapper
  - Increased from 35% to 78.7%
2015-05-06 19:24:15 +02:00
wilderrodrigues
7fd43f33d3 Refactoring the LibvirtComputingResource
- 5 unit tests added
  - KVM hypervisor plugin with 20.1% coverage
2015-05-06 19:24:15 +02:00
wilderrodrigues
0b1b2b6d92 Refactoring the LibvirtComputingResource
- Adding LibvirtCopyVolumeCommandWrapper

Refactoring the LibvirtUtilitiesHelper
  - Changing method name

Did not add any test to this commit due to the refactor mentioned abot.
Will proceed and add the tests

i# Please enter the commit message for your changes. Lines starting
2015-05-06 19:24:15 +02:00
wilderrodrigues
885b9e45d7 Renaming LibvirtConnectionWrapper to LibvirtUtilitiesHelper
- Gave it a better, more suggestive, name since I now added other methods to the class.
  - It makes easier to mock objects and get a better coverage of the classes
2015-05-06 19:24:14 +02:00