[PATCH v2 1/3] Add persistent flag to VM info

Kimchi can manage guests not created by Kimchi. If a user creates a non-persistent domain and uses the Power Off option, it will destroy the user's domain. In order to warn users with non-persistent guests on Power Off, this patch adds a 'persistent' field (like the one for networks and storage pools) to a vm's JSON representation. Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- docs/API.md | 2 ++ src/kimchi/model/vms.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/API.md b/docs/API.md index d75c55f..ebb6e61 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,6 +45,8 @@ the following general conventions: * **POST**: Create a new Virtual Machine * name *(optional)*: The name of the VM. Used to identify the VM in this API. If omitted, a name will be chosen based on the template used. + * persistent: If 'true', vm will persist after a Power Off or host reboot. + All virtual machines created by Kimchi are persistent. * template: The URI of a Template to use when building the VM * storagepool *(optional)*: Assign a specific Storage Pool to the new VM * graphics *(optional)*: Specify the graphics paramenter for this vm diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 476e4ac..5721b48 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -471,7 +471,8 @@ def lookup(self, name): 'ticket': self._get_ticket(dom), 'users': users, 'groups': groups, - 'access': 'full' + 'access': 'full', + 'persistent': True if dom.isPersistent() else False } def _vm_get_disk_paths(self, dom): -- 1.9.3

If the VM is non-persistent, report the danger of using Power Off. If the VM is persistent, warn that data may be lost (the current warning). Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- po/en_US.po | 3 +++ po/pt_BR.po | 3 +++ po/zh_CN.po | 3 +++ ui/js/src/kimchi.guest_main.js | 6 +++++- ui/pages/i18n.json.tmpl | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/po/en_US.po b/po/en_US.po index a34da3a..ef4b127 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -1371,6 +1371,9 @@ msgstr "" "This action may produce undesirable results, for example unflushed disk " "cache in the guest. Would you like to continue?" +msgid "This VM is not persistent. Power Off will delete it. Continue?" +msgstr "This VM is not persistent. Power Off will delete it. Continue?" + msgid "Reset Confirmation" msgstr "Reset Confirmation" diff --git a/po/pt_BR.po b/po/pt_BR.po index 452e778..0edba09 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -1434,6 +1434,9 @@ msgstr "" "Essa ação pode produzir resultados não desejáveis, como por exemplo cache de " "disco não atualizado no guest. Deseja continuar?" +msgid "This VM is not persistent. Power Off will delete it. Continue?" +msgstr "A máquina virtual não é persistente. Desligá-la irá removê-la. Deseja continuar?" + msgid "Reset Confirmation" msgstr "Confirmação de reinicialização" diff --git a/po/zh_CN.po b/po/zh_CN.po index 83c7018..5b6ed6e 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -1318,6 +1318,9 @@ msgid "" "cache in the guest. Would you like to continue?" msgstr "这样做可能导致不良后果,比如客户机磁盘缓存未刷新,确认要继续吗?" +msgid "This VM is not persistent. Power Off will destroy it. Continue?" +msgstr "This VM is not persistent. Power Off will destroy it. Continue?" + msgid "Reset Confirmation" msgstr "重置确认" diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js index ff6f2e1..ff66744 100644 --- a/ui/js/src/kimchi.guest_main.js +++ b/ui/js/src/kimchi.guest_main.js @@ -43,9 +43,13 @@ kimchi.vmpoweroff = function(event) { button.addClass('loading'); var vm=button.closest('li[name=guest]'); var vm_id=vm.attr("id"); + var vmObject=vm.data(); + var vm_persistent=vmObject.persistent == true; + var content_msg = vm_persistent ? i18n['KCHVM6003M'] : + i18n['KCHVM6009M']; var settings = { title : i18n['KCHVM6002M'], - content : i18n['KCHVM6003M'], + content : content_msg, confirm : i18n['KCHAPI6002M'], cancel : i18n['KCHAPI6003M'] }; diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl index cbcd077..fc5d5e4 100644 --- a/ui/pages/i18n.json.tmpl +++ b/ui/pages/i18n.json.tmpl @@ -127,6 +127,7 @@ "KCHVM6006M": "$_("Shut Down Confirmation")", "KCHVM6007M": "$_("Note the guest OS may ignore this request. Would you like to continue?")", "KCHVM6008M": "$_("VM Delete Confirmation")", + "KCHVM6009M": "$_("This VM is not persistent. Power Off will delete it. Continue?")", "KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", "KCHVMCD6002M": "$_("Attach")", -- 1.9.3

-- Reviewed-by: Paulo Vital <pvital@linux.vnet.ibm.com> On Thu, 2014-08-21 at 15:18 -0500, Christy Perez wrote:
If the VM is non-persistent, report the danger of using Power Off. If the VM is persistent, warn that data may be lost (the current warning).
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- po/en_US.po | 3 +++ po/pt_BR.po | 3 +++ po/zh_CN.po | 3 +++ ui/js/src/kimchi.guest_main.js | 6 +++++- ui/pages/i18n.json.tmpl | 1 + 5 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/po/en_US.po b/po/en_US.po index a34da3a..ef4b127 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -1371,6 +1371,9 @@ msgstr "" "This action may produce undesirable results, for example unflushed disk " "cache in the guest. Would you like to continue?"
+msgid "This VM is not persistent. Power Off will delete it. Continue?" +msgstr "This VM is not persistent. Power Off will delete it. Continue?" + msgid "Reset Confirmation" msgstr "Reset Confirmation"
diff --git a/po/pt_BR.po b/po/pt_BR.po index 452e778..0edba09 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -1434,6 +1434,9 @@ msgstr "" "Essa ação pode produzir resultados não desejáveis, como por exemplo cache de " "disco não atualizado no guest. Deseja continuar?"
+msgid "This VM is not persistent. Power Off will delete it. Continue?" +msgstr "A máquina virtual não é persistente. Desligá-la irá removê-la. Deseja continuar?" + msgid "Reset Confirmation" msgstr "Confirmação de reinicialização"
diff --git a/po/zh_CN.po b/po/zh_CN.po index 83c7018..5b6ed6e 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -1318,6 +1318,9 @@ msgid "" "cache in the guest. Would you like to continue?" msgstr "这样做可能导致不良后果,比如客户机磁盘缓存未刷新,确认要继续吗?"
+msgid "This VM is not persistent. Power Off will destroy it. Continue?" +msgstr "This VM is not persistent. Power Off will destroy it. Continue?" + msgid "Reset Confirmation" msgstr "重置确认"
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js index ff6f2e1..ff66744 100644 --- a/ui/js/src/kimchi.guest_main.js +++ b/ui/js/src/kimchi.guest_main.js @@ -43,9 +43,13 @@ kimchi.vmpoweroff = function(event) { button.addClass('loading'); var vm=button.closest('li[name=guest]'); var vm_id=vm.attr("id"); + var vmObject=vm.data(); + var vm_persistent=vmObject.persistent == true; + var content_msg = vm_persistent ? i18n['KCHVM6003M'] : + i18n['KCHVM6009M']; var settings = { title : i18n['KCHVM6002M'], - content : i18n['KCHVM6003M'], + content : content_msg, confirm : i18n['KCHAPI6002M'], cancel : i18n['KCHAPI6003M'] }; diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl index cbcd077..fc5d5e4 100644 --- a/ui/pages/i18n.json.tmpl +++ b/ui/pages/i18n.json.tmpl @@ -127,6 +127,7 @@ "KCHVM6006M": "$_("Shut Down Confirmation")", "KCHVM6007M": "$_("Note the guest OS may ignore this request. Would you like to continue?")", "KCHVM6008M": "$_("VM Delete Confirmation")", + "KCHVM6009M": "$_("This VM is not persistent. Power Off will delete it. Continue?")",
"KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", "KCHVMCD6002M": "$_("Attach")",

Reviewed-by: Crístian Viana <vianac@linux.vnet.ibm.com> On 21-08-2014 17:18, Christy Perez wrote:
If the VM is non-persistent, report the danger of using Power Off. If the VM is persistent, warn that data may be lost (the current warning).
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>

On 2014年08月22日 04:18, Christy Perez wrote:
If the VM is non-persistent, report the danger of using Power Off. If the VM is persistent, warn that data may be lost (the current warning).
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- po/en_US.po | 3 +++ po/pt_BR.po | 3 +++ po/zh_CN.po | 3 +++ ui/js/src/kimchi.guest_main.js | 6 +++++- ui/pages/i18n.json.tmpl | 1 + 5 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/po/en_US.po b/po/en_US.po index a34da3a..ef4b127 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -1371,6 +1371,9 @@ msgstr "" "This action may produce undesirable results, for example unflushed disk " "cache in the guest. Would you like to continue?"
+msgid "This VM is not persistent. Power Off will delete it. Continue?" +msgstr "This VM is not persistent. Power Off will delete it. Continue?" + msgid "Reset Confirmation" msgstr "Reset Confirmation"
diff --git a/po/pt_BR.po b/po/pt_BR.po index 452e778..0edba09 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -1434,6 +1434,9 @@ msgstr "" "Essa ação pode produzir resultados não desejáveis, como por exemplo cache de " "disco não atualizado no guest. Deseja continuar?"
+msgid "This VM is not persistent. Power Off will delete it. Continue?" +msgstr "A máquina virtual não é persistente. Desligá-la irá removê-la. Deseja continuar?" + msgid "Reset Confirmation" msgstr "Confirmação de reinicialização"
diff --git a/po/zh_CN.po b/po/zh_CN.po index 83c7018..5b6ed6e 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -1318,6 +1318,9 @@ msgid "" "cache in the guest. Would you like to continue?" msgstr "这样做可能导致不良后果,比如客户机磁盘缓存未刷新,确认要继续吗?"
+msgid "This VM is not persistent. Power Off will destroy it. Continue?" +msgstr "This VM is not persistent. Power Off will destroy it. Continue?" + 此虚拟机为非持久型虚拟机,关机将导致虚拟机删除,是否继续? msgid "Reset Confirmation" msgstr "重置确认"
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js index ff6f2e1..ff66744 100644 --- a/ui/js/src/kimchi.guest_main.js +++ b/ui/js/src/kimchi.guest_main.js @@ -43,9 +43,13 @@ kimchi.vmpoweroff = function(event) { button.addClass('loading'); var vm=button.closest('li[name=guest]'); var vm_id=vm.attr("id"); + var vmObject=vm.data(); + var vm_persistent=vmObject.persistent == true; + var content_msg = vm_persistent ? i18n['KCHVM6003M'] : + i18n['KCHVM6009M']; var settings = { title : i18n['KCHVM6002M'], - content : i18n['KCHVM6003M'], + content : content_msg, confirm : i18n['KCHAPI6002M'], cancel : i18n['KCHAPI6003M'] }; diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl index cbcd077..fc5d5e4 100644 --- a/ui/pages/i18n.json.tmpl +++ b/ui/pages/i18n.json.tmpl @@ -127,6 +127,7 @@ "KCHVM6006M": "$_("Shut Down Confirmation")", "KCHVM6007M": "$_("Note the guest OS may ignore this request. Would you like to continue?")", "KCHVM6008M": "$_("VM Delete Confirmation")", + "KCHVM6009M": "$_("This VM is not persistent. Power Off will delete it. Continue?")",
"KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", "KCHVMCD6002M": "$_("Attach")",

Also fix tests that were failing as a result of the addition. Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- tests/test_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_model.py b/tests/test_model.py index f5b13d0..59f416c 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -65,7 +65,7 @@ def test_vm_info(self): keys = set(('name', 'state', 'stats', 'uuid', 'memory', 'cpus', 'screenshot', 'icon', 'graphics', 'users', 'groups', - 'access', 'ticket')) + 'access', 'ticket', 'persistent')) stats_keys = set(('cpu_utilization', 'net_throughput', 'net_throughput_peak', @@ -81,6 +81,7 @@ def test_vm_info(self): self.assertRaises(NotFoundError, inst.vm_lookup, 'nosuchvm') self.assertEquals([], info['users']) self.assertEquals([], info['groups']) + self.assertTrue(info['persistent']) @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_lifecycle(self): -- 1.9.3

-- Reviewed-by: Paulo Vital <pvital@linux.vnet.ibm.com> On Thu, 2014-08-21 at 15:18 -0500, Christy Perez wrote:
Also fix tests that were failing as a result of the addition.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- tests/test_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_model.py b/tests/test_model.py index f5b13d0..59f416c 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -65,7 +65,7 @@ def test_vm_info(self):
keys = set(('name', 'state', 'stats', 'uuid', 'memory', 'cpus', 'screenshot', 'icon', 'graphics', 'users', 'groups', - 'access', 'ticket')) + 'access', 'ticket', 'persistent'))
stats_keys = set(('cpu_utilization', 'net_throughput', 'net_throughput_peak', @@ -81,6 +81,7 @@ def test_vm_info(self): self.assertRaises(NotFoundError, inst.vm_lookup, 'nosuchvm') self.assertEquals([], info['users']) self.assertEquals([], info['groups']) + self.assertTrue(info['persistent'])
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_lifecycle(self):

Reviewed-by: Crístian Viana <vianac@linux.vnet.ibm.com> On 21-08-2014 17:18, Christy Perez wrote:
Also fix tests that were failing as a result of the addition.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>

Reviewed-by: Royce Lv<lvroyce@linux.vnet.ibm.com> On 2014年08月22日 04:18, Christy Perez wrote:
Also fix tests that were failing as a result of the addition.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- tests/test_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_model.py b/tests/test_model.py index f5b13d0..59f416c 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -65,7 +65,7 @@ def test_vm_info(self):
keys = set(('name', 'state', 'stats', 'uuid', 'memory', 'cpus', 'screenshot', 'icon', 'graphics', 'users', 'groups', - 'access', 'ticket')) + 'access', 'ticket', 'persistent'))
stats_keys = set(('cpu_utilization', 'net_throughput', 'net_throughput_peak', @@ -81,6 +81,7 @@ def test_vm_info(self): self.assertRaises(NotFoundError, inst.vm_lookup, 'nosuchvm') self.assertEquals([], info['users']) self.assertEquals([], info['groups']) + self.assertTrue(info['persistent'])
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_lifecycle(self):

-- Reviewed-by: Paulo Vital <pvital@linux.vnet.ibm.com> On Thu, 2014-08-21 at 15:18 -0500, Christy Perez wrote:
Kimchi can manage guests not created by Kimchi. If a user creates a non-persistent domain and uses the Power Off option, it will destroy the user's domain. In order to warn users with non-persistent guests on Power Off, this patch adds a 'persistent' field (like the one for networks and storage pools) to a vm's JSON representation.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- docs/API.md | 2 ++ src/kimchi/model/vms.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/API.md b/docs/API.md index d75c55f..ebb6e61 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,6 +45,8 @@ the following general conventions: * **POST**: Create a new Virtual Machine * name *(optional)*: The name of the VM. Used to identify the VM in this API. If omitted, a name will be chosen based on the template used. + * persistent: If 'true', vm will persist after a Power Off or host reboot. + All virtual machines created by Kimchi are persistent. * template: The URI of a Template to use when building the VM * storagepool *(optional)*: Assign a specific Storage Pool to the new VM * graphics *(optional)*: Specify the graphics paramenter for this vm diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 476e4ac..5721b48 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -471,7 +471,8 @@ def lookup(self, name): 'ticket': self._get_ticket(dom), 'users': users, 'groups': groups, - 'access': 'full' + 'access': 'full', + 'persistent': True if dom.isPersistent() else False }
def _vm_get_disk_paths(self, dom):

Reviewed-by: Crístian Viana <vianac@linux.vnet.ibm.com> On 21-08-2014 17:18, Christy Perez wrote:
Kimchi can manage guests not created by Kimchi. If a user creates a non-persistent domain and uses the Power Off option, it will destroy the user's domain. In order to warn users with non-persistent guests on Power Off, this patch adds a 'persistent' field (like the one for networks and storage pools) to a vm's JSON representation.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>

It is not working well for me. 1) I created a vm using a base xml, by running "virsh create vm.xml" <domain type='kvm'> <name>for-test</name> <memory unit='KiB'>10240</memory> <os> <type>hvm</type> <boot dev='hd'/> </os> </domain> 2) Access Kimchi interface and the new vm is displayed 3) Try to power it off. The dialog confirmation is displayed and when I confirm the action an error is shown on top of page "The VM for-test does not exist" 4) Then some a few seconds the VM is removed from Guests tab. On 08/21/2014 05:18 PM, Christy Perez wrote:
Kimchi can manage guests not created by Kimchi. If a user creates a non-persistent domain and uses the Power Off option, it will destroy the user's domain. In order to warn users with non-persistent guests on Power Off, this patch adds a 'persistent' field (like the one for networks and storage pools) to a vm's JSON representation.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- docs/API.md | 2 ++ src/kimchi/model/vms.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/API.md b/docs/API.md index d75c55f..ebb6e61 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,6 +45,8 @@ the following general conventions: * **POST**: Create a new Virtual Machine * name *(optional)*: The name of the VM. Used to identify the VM in this API. If omitted, a name will be chosen based on the template used. + * persistent: If 'true', vm will persist after a Power Off or host reboot. + All virtual machines created by Kimchi are persistent. * template: The URI of a Template to use when building the VM * storagepool *(optional)*: Assign a specific Storage Pool to the new VM * graphics *(optional)*: Specify the graphics paramenter for this vm diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 476e4ac..5721b48 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -471,7 +471,8 @@ def lookup(self, name): 'ticket': self._get_ticket(dom), 'users': users, 'groups': groups, - 'access': 'full' + 'access': 'full', + 'persistent': True if dom.isPersistent() else False }
def _vm_get_disk_paths(self, dom):

On 08/22/2014 07:47 AM, Aline Manera wrote:
It is not working well for me.
1) I created a vm using a base xml, by running "virsh create vm.xml"
<domain type='kvm'> <name>for-test</name> <memory unit='KiB'>10240</memory> <os> <type>hvm</type> <boot dev='hd'/> </os> </domain>
2) Access Kimchi interface and the new vm is displayed 3) Try to power it off. The dialog confirmation is displayed and when I confirm the action an error is shown on top of page "The VM for-test does not exist" 4) Then some a few seconds the VM is removed from Guests tab.
This case needs to be handled outside of this patch, and occurs without my patch. Power Off deletes the VM (hence this warning we're adding). My assumption is that the UI needs to check that a VM exists again before displaying updated stats about it (since this can happen).
On 08/21/2014 05:18 PM, Christy Perez wrote:
Kimchi can manage guests not created by Kimchi. If a user creates a non-persistent domain and uses the Power Off option, it will destroy the user's domain. In order to warn users with non-persistent guests on Power Off, this patch adds a 'persistent' field (like the one for networks and storage pools) to a vm's JSON representation.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- docs/API.md | 2 ++ src/kimchi/model/vms.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/API.md b/docs/API.md index d75c55f..ebb6e61 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,6 +45,8 @@ the following general conventions: * **POST**: Create a new Virtual Machine * name *(optional)*: The name of the VM. Used to identify the VM in this API. If omitted, a name will be chosen based on the template used. + * persistent: If 'true', vm will persist after a Power Off or host reboot. + All virtual machines created by Kimchi are persistent. * template: The URI of a Template to use when building the VM * storagepool *(optional)*: Assign a specific Storage Pool to the new VM * graphics *(optional)*: Specify the graphics paramenter for this vm diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 476e4ac..5721b48 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -471,7 +471,8 @@ def lookup(self, name): 'ticket': self._get_ticket(dom), 'users': users, 'groups': groups, - 'access': 'full' + 'access': 'full', + 'persistent': True if dom.isPersistent() else False }
def _vm_get_disk_paths(self, dom):

After some more investigation, I identified the error was caused in the poweroff request. It is because, after each action, Kimchi tries to get the resource information to return and in the case of a non-persistent VM the resource was deleted. It occurs with/out this patch and probably with all non-persistent resources. I will accept this patch set and open a bug to track this problem. On 08/25/2014 11:57 AM, Christy Perez wrote:
On 08/22/2014 07:47 AM, Aline Manera wrote:
It is not working well for me.
1) I created a vm using a base xml, by running "virsh create vm.xml"
<domain type='kvm'> <name>for-test</name> <memory unit='KiB'>10240</memory> <os> <type>hvm</type> <boot dev='hd'/> </os> </domain>
2) Access Kimchi interface and the new vm is displayed 3) Try to power it off. The dialog confirmation is displayed and when I confirm the action an error is shown on top of page "The VM for-test does not exist" 4) Then some a few seconds the VM is removed from Guests tab. This case needs to be handled outside of this patch, and occurs without my patch. Power Off deletes the VM (hence this warning we're adding).
My assumption is that the UI needs to check that a VM exists again before displaying updated stats about it (since this can happen).
On 08/21/2014 05:18 PM, Christy Perez wrote:
Kimchi can manage guests not created by Kimchi. If a user creates a non-persistent domain and uses the Power Off option, it will destroy the user's domain. In order to warn users with non-persistent guests on Power Off, this patch adds a 'persistent' field (like the one for networks and storage pools) to a vm's JSON representation.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- docs/API.md | 2 ++ src/kimchi/model/vms.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/API.md b/docs/API.md index d75c55f..ebb6e61 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,6 +45,8 @@ the following general conventions: * **POST**: Create a new Virtual Machine * name *(optional)*: The name of the VM. Used to identify the VM in this API. If omitted, a name will be chosen based on the template used. + * persistent: If 'true', vm will persist after a Power Off or host reboot. + All virtual machines created by Kimchi are persistent. * template: The URI of a Template to use when building the VM * storagepool *(optional)*: Assign a specific Storage Pool to the new VM * graphics *(optional)*: Specify the graphics paramenter for this vm diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 476e4ac..5721b48 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -471,7 +471,8 @@ def lookup(self, name): 'ticket': self._get_ticket(dom), 'users': users, 'groups': groups, - 'access': 'full' + 'access': 'full', + 'persistent': True if dom.isPersistent() else False }
def _vm_get_disk_paths(self, dom):

Reviewed-by: Royce Lv<lvroyce@linux.vnet.ibm.com> On 2014年08月22日 04:18, Christy Perez wrote:
Kimchi can manage guests not created by Kimchi. If a user creates a non-persistent domain and uses the Power Off option, it will destroy the user's domain. In order to warn users with non-persistent guests on Power Off, this patch adds a 'persistent' field (like the one for networks and storage pools) to a vm's JSON representation.
Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- docs/API.md | 2 ++ src/kimchi/model/vms.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/API.md b/docs/API.md index d75c55f..ebb6e61 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,6 +45,8 @@ the following general conventions: * **POST**: Create a new Virtual Machine * name *(optional)*: The name of the VM. Used to identify the VM in this API. If omitted, a name will be chosen based on the template used. + * persistent: If 'true', vm will persist after a Power Off or host reboot. + All virtual machines created by Kimchi are persistent. * template: The URI of a Template to use when building the VM * storagepool *(optional)*: Assign a specific Storage Pool to the new VM * graphics *(optional)*: Specify the graphics paramenter for this vm diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 476e4ac..5721b48 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -471,7 +471,8 @@ def lookup(self, name): 'ticket': self._get_ticket(dom), 'users': users, 'groups': groups, - 'access': 'full' + 'access': 'full', + 'persistent': True if dom.isPersistent() else False }
def _vm_get_disk_paths(self, dom):
participants (5)
-
Aline Manera
-
Christy Perez
-
Crístian Viana
-
Paulo Ricardo Paz Vital
-
Royce Lv