Fix state sync logic related to the PAUSED VM state

A VM may get into the paused state not only because the user request
via API calls, but also due to (temporary) external instrumentations.
Before the virt layer can reliably report the reason, we simply ignore
the state discrepancy. In many cases, the VM state will go back to
running after the external instrumentation is done.

Fix bug 1097806.

Change-Id: I8edef45d60fa79d6ddebf7d0438042a7b3986b55
(cherry picked from commit f7fbdeb5672bae7d3bffd6fa76de1ce81fc132bf)
Add a safe_minidom_parse_string function.

Adds a new utils.safe_minidom_parse_string function and
updates external API facing Nova modules to use it.
This ensures we have safe defaults on our incoming API XML parsing.

Internally safe_minidom_parse_string uses a ProtectedExpatParser
class to disable DTDs and entities from being parsed when using
minidom.

Fixes LP Bug #1100282 for Folsom.

Change-Id: I6a4051b5e66f3ce5a330b2589c42e6e9e5b9268e
Enable libvirt to work with NoopFirewallDriver

Fixes bug 1050433

Change-Id: I49613c7d1e6b14411dcdc342366e163a21673f78
Merge "Add a safe_minidom_parse_string function." into stable/folsom
Merge "Enable libvirt to work with NoopFirewallDriver" into stable/folsom
Merge "Fix state sync logic related to the PAUSED VM state" into stable/folsom
Avoid vm instance shutdown when power state is NOSTATE

* nova/compute/manager.py (_sync_power_states): Log the condition
where we can retrieve the state from the hyperviser, rather than
stopping the VM.

Related grizzly commits are 95e77703 and ad101ce5

Fixes bug: 1085771
Change-Id: I5fb9fdc6bcde729c00c4931960ed0de3b8fa189d
libvirt: Fix nova-compute start when missing ip.

If nova-compute is restarted when an instance has no ip address
the libvirt/vif:_get_configuration method will throw an index
error. Check for existance of an ip before attempting to retrieve
one. Includes failing test.

Fixes bug 1131330

Change-Id: Id383544b44e64205fc3b4f850d0d11ad2ebd5da7
VNC Token Validation

Force console auth service to flush all tokens
associated with an instance when it is deleted.
This will fix a bug where the console for the
wrong instance can be connected to via the console
if the correct circumstances occur. This change also
makes a call to veriry vnc console tokens when a
user attempts to connect to a console. This ensures
the user is connecting to the correct console.

bug 1125378
Change-Id: I0d83ec6c4dbfef1af912a200ee15f8052f72da96
Handle compute node not available for live migration

This patch handles exception.ComputeServiceUnavailable by restoring
instance's vm_state and instance's task_state after live migration
failure caused by unavailable source/dest compute node.

Raises detailed HTTPBadRequest explanation for this exception.

Fixes bug 973393 and bug 1051881

Conflicts:
	nova/scheduler/driver.py
	nova/scheduler/manager.py
	nova/tests/api/openstack/compute/contrib/test_admin_actions.py
	nova/tests/scheduler/test_scheduler.py

Change-Id: If825b61fad9c4e3030f2e6c5002907255eaf3661
remove intermediate libvirt downloaded images

* nova/virt/images.py (fetch_to_raw): When converting a downloaded
image to raw, ensure we delete the original download image.
I.E. the .part file.  The regression was introduced in 7c265343.
* nova/tests/test_libvirt.py (test_fetch_raw_image): A new test
for this function which wasn't tested previously.

Conflicts:

	nova/tests/test_libvirt.py
	nova/virt/images.py

Fixes bug: 1125068
Change-Id: Ie6f2cff1a554b8500fd66f0832566ae1b317be40
(cherry picked from commit 1501a4e4f75efb63385a1dadc728c2ef245bf7de)
Ensure we add a new line when appending to rc.local

When we add content to rc.local, if the file already
exists then we need to make sure we add the content
after a new line explicitly

Fixes LP #1089668

Change-Id: I35be1496703b302f732363fa76ce832505eed599
(cherry picked from commit f393a513d7894ddb800e4dfc87da896600fb7421)
Merge "Handle compute node not available for live migration" into stable/folsom
Merge "remove intermediate libvirt downloaded images" into stable/folsom
Merge "VNC Token Validation" into stable/folsom
Merge "Avoid vm instance shutdown when power state is NOSTATE" into stable/folsom
Create util for root device path retrieval

blueprint snapshots-for-everyone

Create libvirt.utils.find_disk(virt_dom) function.
This function will retrieve disk path from instance configuration.
Will return path both for file and device backed instance root devices.
Will throw error in case, when device can't be found.

Change-Id: I612a19221c6ff78079ab53a8d77295c555514c77
Add util for disk type retrieval

blueprint snapshots-for-everyone

Add libvirt.utils.get_disk_type that retrieves format
for given file. Format can be raw, qcow2, or lvm.

Change-Id: I33898983cfa15db6b2654648ce32f72b6dd920cb
Add util for image conversion

blueprint snapshots-for-everyone

Add nova.virt.images.convert_image(source, dest, format)
that converts image to other format using qemu-img convert

Change-Id: I2c92cb31114c42717d0ddd011645dc7c661c82c6
Fixes bug Snapshotting LXC instance fails

Fixes bug 1058273.

The path of the disk for snapshotting LXC instance is debugged.
Also, virt_dom.managedSave(0) and self._create_domain(domain=virt_dom)
are not called for LXC instance, because they are supported by libvirt.

Change-Id: Idf8275a0222b2eb289e16dd245f7721e17fce21d
(cherry picked from commit b60646965de26974f8a8b81f6e43b72a6c8d44f5)