Merge ~raharper/cloud-init:fix/sync-xkvm into cloud-init:master

Proposed by Ryan Harper
Status: Merged
Approved by: Joshua Powers
Approved revision: afd093ba08ba24cd27271de252c5c499e196651d
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/cloud-init:fix/sync-xkvm
Merge into: cloud-init:master
Diff against target: 251 lines (+68/-15)
6 files modified
integration-requirements.txt (+2/-1)
tests/cloud_tests/platforms.yaml (+1/-0)
tests/cloud_tests/platforms/nocloudkvm/instance.py (+9/-4)
tests/cloud_tests/platforms/platforms.py (+1/-1)
tests/cloud_tests/setup_image.py (+2/-1)
tools/xkvm (+53/-8)
Reviewer Review Type Date Requested Status
Joshua Powers (community) Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+370329@code.launchpad.net

Commit message

cloud_tests: updates and fixes

- Update paramiko and cryptography module versions (2.4.2) to
  address issues with algo and deprecation warnings.
- Modify ssh keypair generation to work with updated paramiko
- tools/xkvm sync with newer version from curtin
- Update NoCloudKvm instance.py to work with updated xkvm
  - pass -name to instance, useful for debugging on shared host
  - Add cache_mode platform config; default to cache=none,aio=native
- Switch to yaml.safe_load() in platforms.py

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:afd093ba08ba24cd27271de252c5c499e196651d
https://jenkins.ubuntu.com/server/job/cloud-init-ci/797/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/797/rebuild

review: Approve (continuous-integration)
Revision history for this message
Joshua Powers (powersj) wrote :

LGTM thanks for the clean up!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/integration-requirements.txt b/integration-requirements.txt
index 880d988..fe5ad45 100644
--- a/integration-requirements.txt
+++ b/integration-requirements.txt
@@ -10,7 +10,8 @@ unittest2
10boto3==1.5.910boto3==1.5.9
1111
12# ssh communication12# ssh communication
13paramiko==2.4.113paramiko==2.4.2
14cryptography==2.4.2
1415
1516
16# lxd backend17# lxd backend
diff --git a/tests/cloud_tests/platforms.yaml b/tests/cloud_tests/platforms.yaml
index 448aa98..652a705 100644
--- a/tests/cloud_tests/platforms.yaml
+++ b/tests/cloud_tests/platforms.yaml
@@ -66,5 +66,6 @@ platforms:
66 {{ config_get("user.vendor-data", properties.default) }}66 {{ config_get("user.vendor-data", properties.default) }}
67 nocloud-kvm:67 nocloud-kvm:
68 enabled: true68 enabled: true
69 cache_mode: cache=none,aio=native
6970
70# vi: ts=4 expandtab71# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/platforms/nocloudkvm/instance.py b/tests/cloud_tests/platforms/nocloudkvm/instance.py
index 33ff3f2..96185b7 100644
--- a/tests/cloud_tests/platforms/nocloudkvm/instance.py
+++ b/tests/cloud_tests/platforms/nocloudkvm/instance.py
@@ -74,6 +74,8 @@ class NoCloudKVMInstance(Instance):
74 self.pid_file = None74 self.pid_file = None
75 self.console_file = None75 self.console_file = None
76 self.disk = image_path76 self.disk = image_path
77 self.cache_mode = platform.config.get('cache_mode',
78 'cache=none,aio=native')
77 self.meta_data = meta_data79 self.meta_data = meta_data
7880
79 def shutdown(self, wait=True):81 def shutdown(self, wait=True):
@@ -113,7 +115,10 @@ class NoCloudKVMInstance(Instance):
113 pass115 pass
114116
115 if self.pid_file:117 if self.pid_file:
116 os.remove(self.pid_file)118 try:
119 os.remove(self.pid_file)
120 except Exception:
121 pass
117122
118 self.pid = None123 self.pid = None
119 self._ssh_close()124 self._ssh_close()
@@ -160,13 +165,13 @@ class NoCloudKVMInstance(Instance):
160 self.ssh_port = self.get_free_port()165 self.ssh_port = self.get_free_port()
161166
162 cmd = ['./tools/xkvm',167 cmd = ['./tools/xkvm',
163 '--disk', '%s,cache=unsafe' % self.disk,168 '--disk', '%s,%s' % (self.disk, self.cache_mode),
164 '--disk', '%s,cache=unsafe' % seed,169 '--disk', '%s' % seed,
165 '--netdev', ','.join(['user',170 '--netdev', ','.join(['user',
166 'hostfwd=tcp::%s-:22' % self.ssh_port,171 'hostfwd=tcp::%s-:22' % self.ssh_port,
167 'dnssearch=%s' % CI_DOMAIN]),172 'dnssearch=%s' % CI_DOMAIN]),
168 '--', '-pidfile', self.pid_file, '-vnc', 'none',173 '--', '-pidfile', self.pid_file, '-vnc', 'none',
169 '-m', '2G', '-smp', '2', '-nographic',174 '-m', '2G', '-smp', '2', '-nographic', '-name', self.name,
170 '-serial', 'file:' + self.console_file]175 '-serial', 'file:' + self.console_file]
171 subprocess.Popen(cmd,176 subprocess.Popen(cmd,
172 close_fds=True,177 close_fds=True,
diff --git a/tests/cloud_tests/platforms/platforms.py b/tests/cloud_tests/platforms/platforms.py
index abbfebb..bebdf1c 100644
--- a/tests/cloud_tests/platforms/platforms.py
+++ b/tests/cloud_tests/platforms/platforms.py
@@ -48,7 +48,7 @@ class Platform(object):
48 if os.path.exists(filename):48 if os.path.exists(filename):
49 c_util.del_file(filename)49 c_util.del_file(filename)
5050
51 c_util.subp(['ssh-keygen', '-t', 'rsa', '-b', '4096',51 c_util.subp(['ssh-keygen', '-m', 'PEM', '-t', 'rsa', '-b', '4096',
52 '-f', filename, '-P', '',52 '-f', filename, '-P', '',
53 '-C', 'ubuntu@cloud_test'],53 '-C', 'ubuntu@cloud_test'],
54 capture=True)54 capture=True)
diff --git a/tests/cloud_tests/setup_image.py b/tests/cloud_tests/setup_image.py
index 39f4517..a8aaba1 100644
--- a/tests/cloud_tests/setup_image.py
+++ b/tests/cloud_tests/setup_image.py
@@ -222,7 +222,8 @@ def setup_image(args, image):
222 for name, func, desc in handlers if getattr(args, name, None)]222 for name, func, desc in handlers if getattr(args, name, None)]
223223
224 try:224 try:
225 data = yaml.load(image.read_data("/etc/cloud/build.info", decode=True))225 data = yaml.safe_load(
226 image.read_data("/etc/cloud/build.info", decode=True))
226 info = ' '.join(["%s=%s" % (k, data.get(k))227 info = ' '.join(["%s=%s" % (k, data.get(k))
227 for k in ("build_name", "serial") if k in data])228 for k in ("build_name", "serial") if k in data])
228 except Exception as e:229 except Exception as e:
diff --git a/tools/xkvm b/tools/xkvm
index a30ba91..8d44cad 100755
--- a/tools/xkvm
+++ b/tools/xkvm
@@ -1,4 +1,6 @@
1#!/bin/bash1#!/bin/bash
2# This file is part of cloud-init.
3# See LICENSE file for copyright and license info.
24
3set -f5set -f
46
@@ -11,6 +13,8 @@ TAPDEVS=( )
11# OVS_CLEANUP gets populated with bridge:devname pairs used with ovs13# OVS_CLEANUP gets populated with bridge:devname pairs used with ovs
12OVS_CLEANUP=( )14OVS_CLEANUP=( )
13MAC_PREFIX="52:54:00:12:34"15MAC_PREFIX="52:54:00:12:34"
16# allow this to be set externally.
17_QEMU_SUPPORTS_FILE_LOCKING="${_QEMU_SUPPORTS_FILE_LOCKING}"
14KVM="kvm"18KVM="kvm"
15declare -A KVM_DEVOPTS19declare -A KVM_DEVOPTS
1620
@@ -119,6 +123,21 @@ isdevopt() {
119 return 1123 return 1
120}124}
121125
126qemu_supports_file_locking() {
127 # hackily check if qemu has file.locking in -drive params (LP: #1716028)
128 if [ -z "$_QEMU_SUPPORTS_FILE_LOCKING" ]; then
129 # The only way we could find to check presense of file.locking is
130 # qmp (query-qmp-schema). Simply checking if the virtio-blk driver
131 # supports 'share-rw' is expected to be equivalent and simpler.
132 isdevopt virtio-blk share-rw &&
133 _QEMU_SUPPORTS_FILE_LOCKING=true ||
134 _QEMU_SUPPORTS_FILE_LOCKING=false
135 debug 1 "qemu supports file locking = ${_QEMU_SUPPORTS_FILE_LOCKING}"
136 fi
137 [ "$_QEMU_SUPPORTS_FILE_LOCKING" = "true" ]
138 return
139}
140
122padmac() {141padmac() {
123 # return a full mac, given a subset.142 # return a full mac, given a subset.
124 # assume whatever is input is the last portion to be143 # assume whatever is input is the last portion to be
@@ -367,7 +386,7 @@ main() {
367 [ ${#netdevs[@]} -eq 0 ] && netdevs=( "${DEF_BRIDGE}" )386 [ ${#netdevs[@]} -eq 0 ] && netdevs=( "${DEF_BRIDGE}" )
368 pt=( "$@" )387 pt=( "$@" )
369388
370 local kvm_pkg="" virtio_scsi_bus="virtio-scsi-pci"389 local kvm_pkg="" virtio_scsi_bus="virtio-scsi-pci" virtio_rng_device="virtio-rng-pci"
371 [ -n "$kvm" ] && kvm_pkg="none"390 [ -n "$kvm" ] && kvm_pkg="none"
372 case $(uname -m) in391 case $(uname -m) in
373 i?86)392 i?86)
@@ -382,7 +401,10 @@ main() {
382 [ -n "$kvm" ] ||401 [ -n "$kvm" ] ||
383 { kvm="qemu-system-s390x"; kvm_pkg="qemu-system-misc"; }402 { kvm="qemu-system-s390x"; kvm_pkg="qemu-system-misc"; }
384 def_netmodel=${DEF_NETMODEL:-"virtio-net-ccw"}403 def_netmodel=${DEF_NETMODEL:-"virtio-net-ccw"}
404 # disable virtio-scsi-bus
385 virtio_scsi_bus="virtio-scsi-ccw"405 virtio_scsi_bus="virtio-scsi-ccw"
406 virtio_blk_bus="virtio-blk-ccw"
407 virtio_rng_device="virtio-rng-ccw"
386 ;;408 ;;
387 ppc64*)409 ppc64*)
388 [ -n "$kvm" ] ||410 [ -n "$kvm" ] ||
@@ -408,7 +430,7 @@ main() {
408 bios_opts=( "${_RET[@]}" )430 bios_opts=( "${_RET[@]}" )
409431
410 local out="" fmt="" bus="" unit="" index="" serial="" driver="" devopts=""432 local out="" fmt="" bus="" unit="" index="" serial="" driver="" devopts=""
411 local busorindex="" driveopts="" cur="" val="" file=""433 local busorindex="" driveopts="" cur="" val="" file="" wwn=""
412 for((i=0;i<${#diskdevs[@]};i++)); do434 for((i=0;i<${#diskdevs[@]};i++)); do
413 cur=${diskdevs[$i]}435 cur=${diskdevs[$i]}
414 IFS=","; set -- $cur; IFS="$oifs"436 IFS=","; set -- $cur; IFS="$oifs"
@@ -420,6 +442,7 @@ main() {
420 unit=""442 unit=""
421 index=""443 index=""
422 serial=""444 serial=""
445 wwn=""
423 for tok in "$@"; do446 for tok in "$@"; do
424 [ "${tok#*=}" = "${tok}" -a -f "${tok}" -a -z "$file" ] && file="$tok"447 [ "${tok#*=}" = "${tok}" -a -f "${tok}" -a -z "$file" ] && file="$tok"
425 val=${tok#*=}448 val=${tok#*=}
@@ -433,6 +456,7 @@ main() {
433 file=*) file=$val;;456 file=*) file=$val;;
434 fmt=*|format=*) fmt=$val;;457 fmt=*|format=*) fmt=$val;;
435 serial=*) serial=$val;;458 serial=*) serial=$val;;
459 wwn=*) wwn=$val;;
436 bus=*) bus=$val;;460 bus=*) bus=$val;;
437 unit=*) unit=$val;;461 unit=*) unit=$val;;
438 index=*) index=$val;;462 index=*) index=$val;;
@@ -443,14 +467,19 @@ main() {
443 out=$(LANG=C qemu-img info "$file") &&467 out=$(LANG=C qemu-img info "$file") &&
444 fmt=$(echo "$out" | awk '$0 ~ /^file format:/ { print $3 }') ||468 fmt=$(echo "$out" | awk '$0 ~ /^file format:/ { print $3 }') ||
445 { error "failed to determine format of $file"; return 1; }469 { error "failed to determine format of $file"; return 1; }
446 else470 elif [ -z "$fmt" ]; then
447 fmt=raw471 fmt=raw
448 fi472 fi
449 if [ -z "$driver" ]; then473 if [ -z "$driver" ]; then
450 driver="$def_disk_driver"474 driver="$def_disk_driver"
451 fi475 fi
452 if [ -z "$serial" ]; then476 if [ -z "$serial" ]; then
453 serial="${file##*/}"477 # use filename as serial if not provided a wwn
478 if [ -n "$wwn" ]; then
479 serial="$wwn"
480 else
481 serial="${file##*/}"
482 fi
454 fi483 fi
455484
456 # make sure we add either bus= or index=485 # make sure we add either bus= or index=
@@ -470,11 +499,21 @@ main() {
470 id=*|if=*|driver=*|$file|file=*) continue;;499 id=*|if=*|driver=*|$file|file=*) continue;;
471 fmt=*|format=*) continue;;500 fmt=*|format=*) continue;;
472 serial=*|bus=*|unit=*|index=*) continue;;501 serial=*|bus=*|unit=*|index=*) continue;;
502 file.locking=*)
503 qemu_supports_file_locking || {
504 debug 2 "qemu has no file locking." \
505 "Dropping '$tok' from: $cur"
506 continue
507 };;
473 esac508 esac
474 isdevopt "$driver" "$tok" && devopts="${devopts},$tok" ||509 isdevopt "$driver" "$tok" && devopts="${devopts},$tok" ||
475 diskopts="${diskopts},${tok}"510 diskopts="${diskopts},${tok}"
476 done511 done
477512 case $driver in
513 virtio-blk-ccw)
514 # disable scsi when using virtio-blk-ccw
515 devopts="${devopts},scsi=off";;
516 esac
478 diskargs=( "${diskargs[@]}" -drive "$diskopts" -device "$devopts" )517 diskargs=( "${diskargs[@]}" -drive "$diskopts" -device "$devopts" )
479 done518 done
480519
@@ -623,10 +662,16 @@ main() {
623 done662 done
624663
625 local bus_devices664 local bus_devices
626 bus_devices=( -device "$virtio_scsi_bus,id=virtio-scsi-xkvm" )665 if [ -n "${virtio_scsi_bus}" ]; then
627 cmd=( "${kvmcmd[@]}" "${archopts[@]}" 666 bus_devices=( -device "$virtio_scsi_bus,id=virtio-scsi-xkvm" )
667 fi
668 local rng_devices
669 rng_devices=( -object "rng-random,filename=/dev/urandom,id=objrng0"
670 -device "$virtio_rng_device,rng=objrng0,id=rng0" )
671 cmd=( "${kvmcmd[@]}" "${archopts[@]}"
628 "${bios_opts[@]}"672 "${bios_opts[@]}"
629 "${bus_devices[@]}"673 "${bus_devices[@]}"
674 "${rng_devices[@]}"
630 "${netargs[@]}"675 "${netargs[@]}"
631 "${diskargs[@]}" "${pt[@]}" )676 "${diskargs[@]}" "${pt[@]}" )
632 local pcmd=$(quote_cmd "${cmd[@]}")677 local pcmd=$(quote_cmd "${cmd[@]}")
@@ -661,4 +706,4 @@ else
661 main "$@"706 main "$@"
662fi707fi
663708
664# vi: ts=4 expandtab709# vi: ts=4 expandtab syntax=sh

Subscribers

People subscribed via source and target branches