summaryrefslogtreecommitdiff
path: root/vdservice
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2011-07-24 13:23:27 +0300
committerArnon Gilboa <agilboa@redhat.com>2011-07-24 18:08:03 +0300
commit5edb588d6feec57c281ad8b652d9fae1a9fdedb8 (patch)
tree7e03f7ba5e3f1ebda1592c5f42c3bea7fe72c9a6 /vdservice
parent407acb2288e48281cf1c60c70608f5838ac97c91 (diff)
vdservice: extract init_vdi_port()
Diffstat (limited to 'vdservice')
-rw-r--r--vdservice/vdservice.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 94fe361..b382a6e 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -80,6 +80,7 @@ private:
static DWORD WINAPI control_handler(DWORD control, DWORD event_type,
LPVOID event_data, LPVOID context);
static VOID WINAPI main(DWORD argc, TCHAR * argv[]);
+ bool init_vdi_port();
void set_control_event(int control_command);
void handle_control_event();
void pipe_write_completion();
@@ -454,6 +455,20 @@ VDIPort *create_pci_vdi_port()
return new PCIVDIPort();
}
+bool VDService::init_vdi_port()
+{
+ VDIPort* (*creators[])(void) = { create_virtio_vdi_port, create_pci_vdi_port };
+
+ for (int i = 0 ; i < sizeof(creators)/sizeof(creators[0]); ++i) {
+ _vdi_port = creators[i]();
+ if (_vdi_port->init()) {
+ return true;
+ }
+ delete _vdi_port;
+ }
+ return false;
+}
+
bool VDService::execute()
{
SECURITY_ATTRIBUTES sec_attr;
@@ -488,19 +503,7 @@ bool VDService::execute()
return false;
}
- bool init = false;
- {
- VDIPort* (*creators[])(void) = { create_virtio_vdi_port, create_pci_vdi_port };
- for (int i = 0 ; i < sizeof(creators)/sizeof(creators[0]); ++i) {
- _vdi_port = creators[i]();
- init = _vdi_port->init();
- if (init) {
- break;
- }
- delete _vdi_port;
- }
- }
- if (!init) {
+ if (!init_vdi_port()) {
vd_printf("Failed to create VDIPort instance");
CloseHandle(pipe);
return false;