From 66f93869a40566f6d10ee86be73dd158b12d0ae7 Mon Sep 17 00:00:00 2001 From: Manuel Franceschini <manuel.franceschini@gmail.com> Date: Thu, 24 Apr 2008 15:56:43 +0000 Subject: [PATCH] backend.FinalizeExport: safely initialize some vars This patch initializes nic_count and disk_count with 0. This prevents some reference errors if the snap_disks block device list is empty. Reviewed-by: ultrotter --- lib/backend.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/backend.py b/lib/backend.py index a6b676d74..c56053488 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1215,6 +1215,8 @@ def FinalizeExport(instance, snap_disks): config.set(constants.INISECT_INS, 'memory', '%d' % instance.memory) config.set(constants.INISECT_INS, 'vcpus', '%d' % instance.vcpus) config.set(constants.INISECT_INS, 'disk_template', instance.disk_template) + + nic_count = 0 for nic_count, nic in enumerate(instance.nics): config.set(constants.INISECT_INS, 'nic%d_mac' % nic_count, '%s' % nic.mac) @@ -1223,6 +1225,7 @@ def FinalizeExport(instance, snap_disks): # TODO: redundant: on load can read nics until it doesn't exist config.set(constants.INISECT_INS, 'nic_count' , '%d' % nic_count) + disk_count = 0 for disk_count, disk in enumerate(snap_disks): config.set(constants.INISECT_INS, 'disk%d_ivname' % disk_count, ('%s' % disk.iv_name)) -- GitLab