740 Commits

Author SHA1 Message Date
Rohit Yadav
e2a0d18a84 Merge pull request #696 from iwebhosting/rbd-live-resize
Default to notify only script to handle non-CLVM/QCOW cases.This relates to [CLOUDSTACK-8732](https://issues.apache.org/jira/browse/CLOUDSTACK-8732)

Before this commit the call to `getResizeScriptType` would throw an exception (earlier versions returned `null`, which was fine) - this caused the RBD case to fail. By changing the default to notify only we fix the case for any non-CLVM and non-QCOW cases, too.

This is RBD for now, but this should extend to new storage types supported by Libvirt natively in future.

This is my first attempted contribution: I can see a case for adding RBD logic to the actual getResizeScriptType call, too, but I felt that putting it `LibvirtResizeVolumeCommandWrapper.java` kept the special-casing of RBD (and comments about that) in one place.

### Caveat:

With Libvirt 1.2.2 this actually doesn't do the right thing - but it does do what the documentation *says* should be the right thing, so I'm going to test if this is a Libvirt bug which is fixed in a later version.

(To make it work I need to execute something like:

    virsh blockresize --path vda --size 100G i-7-44-VM

where vda is the path as far as the *guest* is concerned, and not an `rbd/` path - which *should* work, but doesn't.)

* pr/696:
  Default to notify only script to handle non-CLVM/QCOW cases.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-26 16:00:01 +05:30
Rohit Yadav
5d232ea3d9 Merge pull request #735 from shapeblue/kvm-linkbr-checks-master
CLOUDSTACK-8749: Add checks to prevent malformed/unexpected inputBased on @jburwell's comment on PR #718

* pr/735:
  CLOUDSTACK-8749: Add checks to prevent malformed/unexpected input

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-26 14:18:40 +05:30
Rohit Yadav
7e455fa2b7 CLOUDSTACK-8749: Add checks to prevent malformed/unexpected input
Based on @jburwell's comment on PR #718

This closes #735

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-26 13:34:21 +05:30
Koushik Das
e1db6efc74 Removed unused agent command AttachVolumeCommand and corresponding answer AttachVolumeAnswer 2015-08-26 09:50:23 +05:30
Remi Bergsma
87fdb521f0 CLOUDSTACK-8443: don't try to fix co-mounted cgroups
This setting works on CentOS 6 / RHEL 6 but does nothing, as
"cpu" cgroup is not mounted. On CentOS 7 / RHEL 7 systemd does
mount cgroups and "cpu" is co-mounted with "cpuacc". Hence, if
we specify "cpu" then this results in an error because it can
only use them both, or none.

By removing the setting, we rely on the default of qemu, which
is:
cgroup_controllers = ["cpu", "devices", "memory", "blkio", "cpuacct", "net_cls"]

Only if they are really mounted, they will be used. So, this will
work on both version 6 and 7.

The 'fix script' didn't work well, as after a reboot you'd still have qemu
throwing errors. Now we can handle the co-mountedcgroups.
2015-08-24 15:49:40 +02:00
Wei Zhou
92344c006d CLOUDSTACK-5863: revert volume snapshot for KVM/QCOW2 2015-08-24 11:01:50 +02:00
Rohit Yadav
3fd35dd4a7 CLOUDSTACK-8749: KVM - cleanup linklocal interface based on names
This tries to avoid cleaning by a device name.

This closes #718

(cherry picked from commit 74f697a2dd6e2630fa1fa5949e41c7d539015fbf)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-19 21:43:24 +05:30
Remi Bergsma
caa524b01b Merge pull request #630 from manuiiit/pull-2
Fixed Coverity issue "Dereference null return value"Fixed Coverity issue "Dereference null return value"

* pr/630:
  Fixed Coverity issue "Dereference null return value"

Signed-off-by: Remi Bergsma <github@remi.nl>
2015-08-17 08:38:38 +02:00
manuiiit
3cc0fecccc Fixed Coverity issue "Dereference null return value" 2015-08-15 01:34:24 +05:30
Aaron Brady
77a96ed1f7 Default to notify only script to handle non-CLVM/QCOW cases.
Before this commit the call to `getResizeScriptType` would throw
an exception (earlier versions returned `null`, which was fine) -
this caused the RBD case to fail. By changing the default to
notify only we fix the case for any non-CLVM and non-QCOW cases.

This is RBD for now, but this should extend to new storage
types suppored by Libvirt natively in future.
2015-08-14 12:15:07 +01:00
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
Rohit Yadav
5d29b63cfa CLOUDSTACK-8613, CLOUDSTACK-6301: Dump KVM domain XML with secure flag
When dumping XML use appropriate flags:

1, VIR_DOMAIN_XML_SECURE (dump security sensitive information too)
8, VIR_DOMAIN_XML_MIGRATABLE (dump XML suitable for migration)

Source:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainXMLFlags

This fixes CVE 2015-3252: VNC password lost during VM migration across KVM
hosts. The issue is also seen when a VM is rebooted.

(cherry picked from commit cb2aca751630ea60ad2fffed3d12e3fa2a5e93b5)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 10:57:36 +05:30
Daan Hoogland
e2b6237464 CLOUDSTACK-8656: debug messages on interupted exceptions 2015-07-30 16:03:10 +02:00
Maneesha P
1f09b8c3bf Fixed Coverity issue "Dereference null return value"
added a not null check and a CloudRuntimeException in case of null

Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>

This closes #617
2015-07-23 15:46:17 +05:30
Wido den Hollander
d1f76a2a84 CLOUDSTACK-8628: kvm: Disable Fencing when no NFS storage pools are present
On NFS we write a heartbeat, but without those we can not safely
fence off a host.

If we fence without knowing about a heartbeat we can cause a split-brain situation.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2015-07-17 12:33:11 +02:00
Daan Hoogland
c53959513e findbugs: create wrapper to deal with static field
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #573
2015-07-14 11:50:39 +02:00
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
Wido den Hollander
63688e70a0 kvm: More verbose logging around storage pools in the Agent 2015-07-13 16:53:26 +02:00
Wido den Hollander
24f8e66e93 kvm: Write Libvirt instead of LibVirt 2015-07-13 16:22:33 +02:00
Wido den Hollander
7c37ba73a3 kvm: Add more verbose logging about what is happening with Libvirt connections 2015-07-13 16:21:41 +02:00
Daan Hoogland
bcc8182f2f findbugs: write to static from instance these are the trivial cases of ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD as reported by findbugs
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #539
2015-07-09 15:01:58 +02:00
Daan Hoogland
31c6b14dd4 Merge branch 'improvement/CLOUDSTACK-8607' change the host password on the host itself via the updateHostPassword API
- Make sure the new password replaces the old one in the queue
    - Updated the patch files for XenServer
    - Updated the script path on LibvirtComputing class
    - Adding update_host_passwd to VRScripts
    - Add implementation to CitrixUpdateHostPasswordCommandWrapper
    - Improve testUpdateHostPasswordCommand() unit test on CitrixRequestWrapperTest
    - Adding update_host_passwd.sh script
    - Adding the host IP address as an instance variable on UpdateHostPasswordCommand
    - Improving the Unit Test (LibvirtComputingResourceTest) to get it covering the new code
    - Make sure doUpdateHostPassword() doesn't get called if flag is set to false
    - Do not update XenServer hosts if the cluster ID is not informed

    This closes #559
2015-07-06 16:15:22 +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
efa34361df CLOUDSTACK-8607 - Changed update script to return exit code based on the result
- Changed location of the update_host_passwd script
   - Updated the patch files for XenServer
   - Updated the script path on LibvirtComputing class
   - Removed the hostIP from the LibvirtUpdateHostPasswordCommandWrapper execute() method
2015-07-03 14:29:57 +02:00
Kishan Kavala
3a19a8916e BUG-ID:CLOUDSTACK-7472: kvmclock fix for LXC is not required after fixing CLOUDSTACK-8177
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #557
2015-07-03 15:21:18 +05:30
wilderrodrigues
0dd02ce043 CLOUDSTACK-8607 - Adding support to update host passwd on XenServer hypervisors
- Adding update_host_passwd to VRScripts
   - Add accessor method to host password on CitrixResourceBase
   - Add implementation to CitrixUpdateHostPasswordCommandWrapper
   - Improve testUpdateHostPasswordCommand() unit test on CitrixRequestWrapperTest
   - Add line to patch files on xenserver directory

Concerning the LibVirt change:

   - I forgot to assing the return of the getDefaultHypervisorScriptsDir() method to the hypervisorScriptsDir variable
2015-07-03 10:24:44 +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
Daan Hoogland
bbb165a037 findbugs: use preferred encoding explicitly 2015-06-20 10:36:15 +02:00
Daan Hoogland
e3407a3939 findbugs: encoding using preferred Charset 2015-06-19 23:03:05 +02:00
Wido den Hollander
4b4c52ea77 CLOUDSTACK-8560: Stat the resulting image after copying from template and return the size
This way we update the DB with the actual size of the disk after deployment from template
2015-06-15 17:55:56 +02:00
Rafael da Fonseca
ccd7d41ee3 Resolve findbugs encoding warning
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #392
2015-06-15 12:07:55 +03:00
Rafael da Fonseca
f8b364b7c7 Was safe either way as this piece of code should only run in linux, this just gets rid of the findbugs warning
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #402
2015-06-15 12:04:47 +03:00
Rafael da Fonseca
3299f23ea2 Fix findbugs encoding warning in LibvirtCreatePrivateTemplateFromVolumeCommandWrapper Libvirt templates should be written in UTF-8, default was already doing that so this just gets rid of the findbugs warning
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #401
2015-06-15 12:04:24 +03:00
Rafael da Fonseca
949e97dec6 Fix findbugs warning in LibvirtConsoleProxyLoadCommandWrapper Encoding is now specified in both server and clients for the console proxy getstatus command For some reason, findbugs did not detect unsafe encoding issue in ConsoleProxyResource.java, is properly specified now though... CitrixConsoleProxyLoadCommandWrapper was specifying system default encoding for operation, should be ok because default for xenserver is UTF-8 since it's linux based, but it's best to specify exact encoding set on the server end to be consistent
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-06-15 12:04:18 +03:00
wilderrodrigues
93845afd53 Using a try-wioth resrouce block as suggested in @DaanHoogland review.
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #355
2015-06-04 12:34:05 +02:00
wilderrodrigues
7f4e2c7cf0 Renaming the variable from "s" to "script"
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>
2015-06-04 12:34:05 +02:00
wilderrodrigues
6138d9a690 Coverity issue 1116812 - Replacing concatenation with optionsBuffer.append(option.getKey()).append('=').append(option.getValue()).append(',');
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>
2015-06-04 12:34:05 +02:00
wilderrodrigues
9ff38486a1 Coverity issue 1116677 - Avoiding catching only Exception. Makes the code too britle. - Catching the QemuImgException and throwing it to be caught further in the code - Surrounding the output stream with try/catch and throwing it to be further handled in the code. Closing the output stream quietly.
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>
2015-06-04 12:34:05 +02:00
wilderrodrigues
6271663682 Formatting the code - Adding final modifier and indenting the code
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>
2015-06-04 12:34:04 +02:00
Daan Hoogland
3d4d152753 CID 1302976 Scanner in try-with-resource
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #352
2015-06-04 00:09:40 +02:00
Daan Hoogland
109b6e94d3 CID 1302974: Scanner in try-with-resource
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #353
2015-06-04 00:09:16 +02:00
Rohit Yadav
f341246888 CLOUDSTACK-8530: KVM hosts without active agents should be in Disconnected state
KVM hosts which are actuall up, but if their agents are shutdown should be put
in disconnected state. This would avoid getting the VMs HA'd and other commands
such as deploying a VM will exclude that host and save us from errors.

The improvement is that, we first try to contact the KVM host itself. If it fails
we assume that it's disconnected, and then ask its KVM neighbours if they can
check its status. If all of the KVM neighbours tell us that it's Down and we're
unable to reach the KVM host, then the host is possibly down. In case any of the
KVM neighbours tell us that it's Up but we're unable to reach the KVM host then
we can be sure that the agent is offline but the host is running.

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

This closes #340
2015-06-02 13:27:16 +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
wilderrodrigues
ce9014d2ec Fix the NPE tht was being caught by the executeRequest() method. - The LibvirtUtilitiesHelper should have been injected, but it did not work on the Agent side. Due to that, when sending a StartCommand we were experiencing NPE, which made impossible to get SSVM/CPVM started. - The LibvirtUtilitiesHelper class is now being instantiated withing the LibvirtComputingResource
Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>

This closes #318
2015-05-27 13:19:57 +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
9dcfbceae7 kvm: for disabling pxe, pass empty file
Passing the file argument to the xml break for EL 7.1, the fix removes
the argument as just passing rombar='off' with its file arg to be empty string.

This closes #290

(cherry picked from commit aafa0c80b35a9f0e533e5a4b18d03f1e47cf9bfe)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-05-25 00:31:32 +02:00
Rohit Yadav
d7f4498f76 kvm: Strip trailing comma for qemu-img convert options
Fix trailing comma for qemu-img convert options, Qemu 2.0+ not tolerant to it

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 90ac1aba13d431cdccf51dde2c4727b96388d985)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-05-22 13:33:54 +01: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