summaryrefslogtreecommitdiff
path: root/stream-servers/GfxStreamBackend.cpp
blob: 19fa7460e45e7ecd62474545d56076b945aedc2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "base/MemStream.h"
#include "base/PathUtils.h"
#include "base/System.h"
#include "host-common/address_space_device.h"
#include "host-common/address_space_device.hpp"
#include "host-common/address_space_graphics.h"
#include "host-common/address_space_graphics_types.h"
#include "host-common/AndroidPipe.h"
#include "host-common/android_pipe_device.h"
#include "host-common/vm_operations.h"
#include "host-common/window_agent.h"
#include "host-common/HostmemIdMapping.h"
#include "host-common/FeatureControl.h"
#include "host-common/feature_control.h"
#include "host-common/opengl/emugl_config.h"
#include "host-common/opengles-pipe.h"
#include "host-common/opengles.h"
#include "host-common/refcount-pipe.h"
#include "host-common/globals.h"
#include "snapshot/interface.h"

#include <fstream>
#include <string>

#include <stdio.h>

#include "VulkanDispatch.h"
#include "GfxStreamAgents.h"
#include "render_api.h"

#define GFXSTREAM_DEBUG_LEVEL 1

#if GFXSTREAM_DEBUG_LEVEL >= 1
#define GFXS_LOG(fmt, ...)                                                     \
    do {                                                                       \
        fprintf(stdout, "%s:%d " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); \
        fflush(stdout);                                                        \
    } while (0)

#else
#define GFXS_LOG(fmt,...)
#endif

extern "C" {
#include "host-common/goldfish_pipe.h"
#include "virtio-gpu-gfxstream-renderer.h"
}  // extern "C"

using android::AndroidPipe;
using android::base::pj;

#ifdef _WIN32
#define VG_EXPORT __declspec(dllexport)
#else
#define VG_EXPORT __attribute__((visibility("default")))
#endif

#define POST_CALLBACK_DISPLAY_TYPE_X 0
#define POST_CALLBACK_DISPLAY_TYPE_WAYLAND_SHARED_MEM 1
#define POST_CALLBACK_DISPLAY_TYPE_WINDOWS_HWND 2

struct renderer_display_info;
typedef void (*get_pixels_t)(void*, uint32_t, uint32_t);
static get_pixels_t sGetPixelsFunc = 0;
typedef void (*post_callback_t)(void*, uint32_t, int, int, int, int, int, unsigned char*);



extern "C" VG_EXPORT void gfxstream_backend_init(
    uint32_t display_width,
    uint32_t display_height,
    uint32_t display_type,
    void* renderer_cookie,
    int renderer_flags,
    struct virgl_renderer_callbacks* virglrenderer_callbacks);

extern "C" VG_EXPORT void gfxstream_backend_setup_window(
        void* native_window_handle,
        int32_t window_x,
        int32_t window_y,
        int32_t window_width,
        int32_t window_height,
        int32_t fb_width,
        int32_t fb_height);

// For reading back rendered contents to display
extern "C" VG_EXPORT void get_pixels(void* pixels, uint32_t bytes);

static const GoldfishPipeServiceOps goldfish_pipe_service_ops = {
        // guest_open()
        [](GoldfishHwPipe* hwPipe) -> GoldfishHostPipe* {
            return static_cast<GoldfishHostPipe*>(
                    android_pipe_guest_open(hwPipe));
        },
        // guest_open_with_flags()
        [](GoldfishHwPipe* hwPipe, uint32_t flags) -> GoldfishHostPipe* {
            return static_cast<GoldfishHostPipe*>(
                    android_pipe_guest_open_with_flags(hwPipe, flags));
        },
        // guest_close()
        [](GoldfishHostPipe* hostPipe, GoldfishPipeCloseReason reason) {
            static_assert((int)GOLDFISH_PIPE_CLOSE_GRACEFUL ==
                                  (int)PIPE_CLOSE_GRACEFUL,
                          "Invalid PIPE_CLOSE_GRACEFUL value");
            static_assert(
                    (int)GOLDFISH_PIPE_CLOSE_REBOOT == (int)PIPE_CLOSE_REBOOT,
                    "Invalid PIPE_CLOSE_REBOOT value");
            static_assert((int)GOLDFISH_PIPE_CLOSE_LOAD_SNAPSHOT ==
                                  (int)PIPE_CLOSE_LOAD_SNAPSHOT,
                          "Invalid PIPE_CLOSE_LOAD_SNAPSHOT value");
            static_assert(
                    (int)GOLDFISH_PIPE_CLOSE_ERROR == (int)PIPE_CLOSE_ERROR,
                    "Invalid PIPE_CLOSE_ERROR value");

            android_pipe_guest_close(hostPipe,
                                     static_cast<PipeCloseReason>(reason));
        },
        // guest_pre_load()
        [](QEMUFile* file) { (void)file; },
        // guest_post_load()
        [](QEMUFile* file) { (void)file; },
        // guest_pre_save()
        [](QEMUFile* file) { (void)file; },
        // guest_post_save()
        [](QEMUFile* file) { (void)file; },
        // guest_load()
        [](QEMUFile* file,
           GoldfishHwPipe* hwPipe,
           char* force_close) -> GoldfishHostPipe* {
            (void)file;
            (void)hwPipe;
            (void)force_close;
           return nullptr;
        },
        // guest_save()
        [](GoldfishHostPipe* hostPipe, QEMUFile* file) {
            (void)hostPipe;
            (void)file;
        },
        // guest_poll()
        [](GoldfishHostPipe* hostPipe) {
            static_assert((int)GOLDFISH_PIPE_POLL_IN == (int)PIPE_POLL_IN,
                          "invalid POLL_IN values");
            static_assert((int)GOLDFISH_PIPE_POLL_OUT == (int)PIPE_POLL_OUT,
                          "invalid POLL_OUT values");
            static_assert((int)GOLDFISH_PIPE_POLL_HUP == (int)PIPE_POLL_HUP,
                          "invalid POLL_HUP values");

            return static_cast<GoldfishPipePollFlags>(
                    android_pipe_guest_poll(hostPipe));
        },
        // guest_recv()
        [](GoldfishHostPipe* hostPipe,
           GoldfishPipeBuffer* buffers,
           int numBuffers) -> int {
            // NOTE: Assumes that AndroidPipeBuffer and GoldfishPipeBuffer
            //       have exactly the same layout.
            static_assert(
                    sizeof(AndroidPipeBuffer) == sizeof(GoldfishPipeBuffer),
                    "Invalid PipeBuffer sizes");
        // We can't use a static_assert with offsetof() because in msvc, it uses
        // reinterpret_cast.
        // TODO: Add runtime assertion instead?
        // https://developercommunity.visualstudio.com/content/problem/22196/static-assert-cannot-compile-constexprs-method-tha.html
#ifndef _MSC_VER
            static_assert(offsetof(AndroidPipeBuffer, data) ==
                                  offsetof(GoldfishPipeBuffer, data),
                          "Invalid PipeBuffer::data offsets");
            static_assert(offsetof(AndroidPipeBuffer, size) ==
                                  offsetof(GoldfishPipeBuffer, size),
                          "Invalid PipeBuffer::size offsets");
#endif
            return android_pipe_guest_recv(
                    hostPipe, reinterpret_cast<AndroidPipeBuffer*>(buffers),
                    numBuffers);
        },
        // guest_send()
        [](GoldfishHostPipe** hostPipe,
           const GoldfishPipeBuffer* buffers,
           int numBuffers) -> int {
            return android_pipe_guest_send(
                    reinterpret_cast<void**>(hostPipe),
                    reinterpret_cast<const AndroidPipeBuffer*>(buffers),
                    numBuffers);
        },
        // guest_wake_on()
        [](GoldfishHostPipe* hostPipe, GoldfishPipeWakeFlags wakeFlags) {
            android_pipe_guest_wake_on(hostPipe, static_cast<int>(wakeFlags));
        },
        // dma_add_buffer()
        [](void* pipe, uint64_t paddr, uint64_t sz) {
            // not considered for virtio
        },
        // dma_remove_buffer()
        [](uint64_t paddr) {
            // not considered for virtio
        },
        // dma_invalidate_host_mappings()
        []() {
            // not considered for virtio
        },
        // dma_reset_host_mappings()
        []() {
            // not considered for virtio
        },
        // dma_save_mappings()
        [](QEMUFile* file) {
            (void)file;
        },
        // dma_load_mappings()
        [](QEMUFile* file) {
            (void)file;
        },
};

extern const QAndroidVmOperations* const gQAndroidVmOperations;

static void set_post_callback(struct renderer_display_info* r, post_callback_t func, uint32_t display_type);

static void default_post_callback(
    void* context, uint32_t displayId, int width, int height, int ydir, int format, int frame_type, unsigned char* pixels) {
    (void)context;
    (void)width;
    (void)height;
    (void)ydir;
    (void)format;
    (void)frame_type;
    (void)pixels;
    // no-op
}

uint32_t sBackendFlags = 0;

enum BackendFlags {
    GFXSTREAM_BACKEND_FLAGS_NO_VK_BIT = 1 << 0,
    GFXSTREAM_BACKEND_FLAGS_EGL2EGL_BIT = 1 << 1,
};

// Sets backend flags for different kinds of initialization.
// Default (and default if not called): flags == 0
// Needs to be called before |gfxstream_backend_init|.
extern "C" VG_EXPORT void gfxstream_backend_set_flags(uint32_t flags) {
    sBackendFlags = flags;
}

extern "C" VG_EXPORT void gfxstream_backend_init(
    uint32_t display_width,
    uint32_t display_height,
    uint32_t display_type,
    void* renderer_cookie,
    int renderer_flags,
    struct virgl_renderer_callbacks* virglrenderer_callbacks) {


    // First we make some agents available.


    GFXS_LOG("start. display dimensions: width %u height %u. backend flags: 0x%x renderer flags: 0x%x",
             display_width, display_height, sBackendFlags, renderer_flags);

    AvdInfo** avdInfoPtr = aemu_get_android_avdInfoPtr();

    (*avdInfoPtr) = avdInfo_newCustom(
        "goldfish_opengl_test",
        28,
        "x86_64",
        "x86_64",
        true /* is google APIs */,
        AVD_PHONE);

    // Flags processing

    // TODO: hook up "gfxstream egl" to the renderer flags
    // GFXSTREAM_RENDERER_FLAGS_USE_EGL_BIT in crosvm
    // as it's specified from launch_cvd.
    // At the moment, use ANDROID_GFXSTREAM_EGL=1
    // For test on GCE
    if (android::base::getEnvironmentVariable("ANDROID_GFXSTREAM_EGL") == "1") {
        android::base::setEnvironmentVariable("ANDROID_EGL_ON_EGL", "1");
        android::base::setEnvironmentVariable("ANDROID_EMUGL_LOG_PRINT", "1");
        android::base::setEnvironmentVariable("ANDROID_EMUGL_VERBOSE", "1");
    }
    // end for test on GCE

    android::base::setEnvironmentVariable("ANDROID_EMU_HEADLESS", "1");
    android::base::setEnvironmentVariable("ANDROID_EMU_SANDBOX", "1");
    android::base::setEnvironmentVariable("ANDROID_EMUGL_FIXED_BACKEND_LIST", "1");
    bool vkDisabledByEnv = android::base::getEnvironmentVariable("ANDROID_EMU_DISABLE_VULKAN") == "1";
    bool vkDisabledByFlag =
        (sBackendFlags & GFXSTREAM_BACKEND_FLAGS_NO_VK_BIT) ||
        (renderer_flags & GFXSTREAM_RENDERER_FLAGS_NO_VK_BIT);
    bool enableVk = !vkDisabledByEnv && !vkDisabledByFlag;

    bool egl2eglByEnv = android::base::getEnvironmentVariable("ANDROID_EGL_ON_EGL") == "1";
    bool egl2eglByFlag = renderer_flags & GFXSTREAM_RENDERER_FLAGS_USE_EGL_BIT;
    bool enable_egl2egl = egl2eglByFlag || egl2eglByEnv;
    if (enable_egl2egl) {
        android::base::setEnvironmentVariable("ANDROID_GFXSTREAM_EGL", "1");
        android::base::setEnvironmentVariable("ANDROID_EGL_ON_EGL", "1");
    }

    bool ignoreHostGlErrorsFlag = renderer_flags & GFXSTREAM_RENDERER_FLAGS_IGNORE_HOST_GL_ERRORS_BIT;
    bool nativeTextureDecompression = renderer_flags & GFXSTREAM_RENDERER_FLAGS_NATIVE_TEXTURE_DECOMPRESSION_BIT;
    bool bptcTextureSupport = renderer_flags & GFXSTREAM_RENDERER_FLAGS_ENABLE_BPTC_TEXTURES_BIT;
    bool s3tcTextureSupport = renderer_flags & GFXSTREAM_RENDERER_FLAGS_ENABLE_S3TC_TEXTURES_BIT;
    bool syncFdDisabledByFlag = renderer_flags & GFXSTREAM_RENDERER_FLAGS_NO_SYNCFD_BIT;
    bool surfaceless =
            renderer_flags & GFXSTREAM_RENDERER_FLAGS_USE_SURFACELESS_BIT;
    bool enableGlEs31Flag = renderer_flags & GFXSTREAM_RENDERER_FLAGS_ENABLE_GLES31_BIT;
    bool guestUsesAngle = renderer_flags & GFXSTREAM_RENDERER_FLAGS_GUEST_USES_ANGLE;
    bool useVulkanNativeSwapchain =
        renderer_flags & GFXSTREAM_RENDERER_FLAGS_VULKAN_NATIVE_SWAPCHAIN_BIT;

    GFXS_LOG("Vulkan enabled? %d", enableVk);
    GFXS_LOG("egl2egl enabled? %d", enable_egl2egl);
    GFXS_LOG("ignore host gl errors enabled? %d", ignoreHostGlErrorsFlag);
    GFXS_LOG("syncfd enabled? %d", !syncFdDisabledByFlag);
    GFXS_LOG("use native texture decompression if available? %d", nativeTextureDecompression);
    GFXS_LOG("enable BPTC support if available? %d", bptcTextureSupport);
    GFXS_LOG("enable S3TC support if available? %d", s3tcTextureSupport);
    GFXS_LOG("surfaceless? %d", surfaceless);
    GFXS_LOG("OpenGL ES 3.1 enabled? %d", enableGlEs31Flag);
    GFXS_LOG("guest using ANGLE? %d", guestUsesAngle);
    GFXS_LOG("use Vulkan native swapchain on the host? %d",
             useVulkanNativeSwapchain);

    // Need to manually set the GLES backend paths in gfxstream environment
    // because the library search paths are not automatically set to include
    // the directory in whioch the GLES backend resides.
#if defined(__linux__)
#define GFXSTREAM_LIB_SUFFIX ".so"
#elif defined(__APPLE__)
#define GFXSTREAM_LIB_SUFFIX ".dylib"
#else // Windows
#define GFXSTREAM_LIB_SUFFIX ".dll"
#endif

    feature_set_enabled_override(
            kFeature_GLPipeChecksum, false);
    feature_set_enabled_override(
            kFeature_GLESDynamicVersion, true);
    feature_set_enabled_override(
            kFeature_PlayStoreImage, !enableGlEs31Flag);
    feature_set_enabled_override(
            kFeature_GLDMA, false);
    feature_set_enabled_override(
            kFeature_GLAsyncSwap, false);
    feature_set_enabled_override(
            kFeature_RefCountPipe, false);
    feature_set_enabled_override(
            kFeature_NoDelayCloseColorBuffer, true);
    feature_set_enabled_override(
            kFeature_IgnoreHostOpenGLErrors, ignoreHostGlErrorsFlag);
    feature_set_enabled_override(
            kFeature_NativeTextureDecompression, nativeTextureDecompression);
    feature_set_enabled_override(
            kFeature_BptcTextureSupport, bptcTextureSupport);
    feature_set_enabled_override(
            kFeature_S3tcTextureSupport, s3tcTextureSupport);
    feature_set_enabled_override(
            kFeature_GLDirectMem, false);
    feature_set_enabled_override(
            kFeature_Vulkan, enableVk);
    feature_set_enabled_override(
            kFeature_VulkanSnapshots, false);
    feature_set_enabled_override(
            kFeature_VulkanNullOptionalStrings, true);
    feature_set_enabled_override(
            kFeature_VulkanShaderFloat16Int8, true);
    feature_set_enabled_override(
            kFeature_HostComposition, true);
    feature_set_enabled_override(
            kFeature_VulkanIgnoredHandles, true);
    feature_set_enabled_override(
            kFeature_VirtioGpuNext, true);
    feature_set_enabled_override(
            kFeature_VirtioGpuNativeSync, !syncFdDisabledByFlag);
    feature_set_enabled_override(
            kFeature_GuestUsesAngle, guestUsesAngle);
    feature_set_enabled_override(
            kFeature_VulkanQueueSubmitWithCommands, true);
    feature_set_enabled_override(kFeature_VulkanNativeSwapchain,
                                 useVulkanNativeSwapchain);
    feature_set_enabled_override(
            kFeature_VulkanBatchedDescriptorSetUpdate, true);

    if (useVulkanNativeSwapchain && !enableVk) {
        fprintf(stderr,
                "%s: can't enable vulkan native swapchain, Vulkan is disabled, "
                "fatal\n",
                __func__);
        abort();
    }

    emugl::vkDispatch(false /* don't use test ICD */);

    auto androidHw = aemu_get_android_hw();

    androidHw->hw_gltransport_asg_writeBufferSize = 1048576;
    androidHw->hw_gltransport_asg_writeStepSize = 262144;
    androidHw->hw_gltransport_asg_dataRingSize = 524288;
    androidHw->hw_gltransport_drawFlushInterval = 10000;

    EmuglConfig config;

    // Make all the console agents available.
    android::emulation::injectConsoleAgents(android::emulation::GfxStreamAndroidConsoleFactory());

    emuglConfig_init(&config, true /* gpu enabled */, "auto",
                     enable_egl2egl ? "swiftshader_indirect" : "host",
                     64,          /* bitness */
                     surfaceless, /* no window */
                     false,       /* blacklisted */
                     false,       /* has guest renderer */
                     WINSYS_GLESBACKEND_PREFERENCE_AUTO,
                     true /* force host gpu vulkan */);

    emuglConfig_setupEnv(&config);

    android_prepareOpenglesEmulation();

    {
        static emugl::RenderLibPtr renderLibPtr = initLibrary();
        void* egldispatch = renderLibPtr->getEGLDispatch();
        void* glesv2Dispatch = renderLibPtr->getGLESv2Dispatch();
        android_setOpenglesEmulation(
                renderLibPtr.get(), egldispatch, glesv2Dispatch);
    }

    int maj;
    int min;
    android_startOpenglesRenderer(
        display_width, display_height, 1, 28,
        getConsoleAgents()->vm,
        getConsoleAgents()->emu,
        getConsoleAgents()->multi_display,
        &maj, &min);

    char* vendor = nullptr;
    char* renderer = nullptr;
    char* version = nullptr;

    android_getOpenglesHardwareStrings(
        &vendor, &renderer, &version);

    GFXS_LOG("GL strings; [%s] [%s] [%s].\n",
             vendor, renderer, version);

    auto openglesRenderer = android_getOpenglesRenderer();

    if (!openglesRenderer) {
        fprintf(stderr, "%s: no renderer started, fatal\n", __func__);
        abort();
    }

    address_space_set_vm_operations(getConsoleAgents()->vm);
    android_init_opengles_pipe();
    android_opengles_pipe_set_recv_mode(2 /* virtio-gpu */);
    android_init_refcount_pipe();

    sGetPixelsFunc = android_getReadPixelsFunc();

    pipe_virgl_renderer_init(renderer_cookie, renderer_flags, virglrenderer_callbacks);

    GFXS_LOG("Started renderer");

    if (surfaceless) {
        set_post_callback(nullptr, default_post_callback, display_type);
    }
}

extern "C" VG_EXPORT void gfxstream_backend_setup_window(
        void* native_window_handle,
        int32_t window_x,
        int32_t window_y,
        int32_t window_width,
        int32_t window_height,
        int32_t fb_width,
        int32_t fb_height) {
    android_showOpenglesWindow(native_window_handle, window_x, window_y,
                               window_width, window_height, fb_width, fb_height,
                               1.0f, 0, false, false);
}

static void set_post_callback(struct renderer_display_info* r, post_callback_t func, uint32_t display_type) {

    // crosvm needs bgra readback depending on the display type
    bool use_bgra_readback = false;
    switch (display_type) {
        case POST_CALLBACK_DISPLAY_TYPE_X:
            GFXS_LOG("using display type: X11");
            use_bgra_readback = true;
            break;
        case POST_CALLBACK_DISPLAY_TYPE_WAYLAND_SHARED_MEM:
            GFXS_LOG("using display type: wayland shared mem");
            break;
        case POST_CALLBACK_DISPLAY_TYPE_WINDOWS_HWND:
            GFXS_LOG("using display type: windows hwnd");
            break;
        default:
            break;
    }

    android_setPostCallback(func, r, false, 0);
}

extern "C" VG_EXPORT void gfxstream_backend_teardown() {
    android_finishOpenglesRenderer();
    android_hideOpenglesWindow();
    android_stopOpenglesRenderer(true);
}

extern "C" VG_EXPORT void gfxstream_backend_set_screen_mask(int width, int height, const unsigned char* rgbaData) {
    android_setOpenglesScreenMask(width, height, rgbaData);
}

extern "C" VG_EXPORT void get_pixels(void* pixels, uint32_t bytes) {
    //TODO: support display > 0
    sGetPixelsFunc(pixels, bytes, 0);
}

extern "C" const GoldfishPipeServiceOps* goldfish_pipe_get_service_ops() {
    return &goldfish_pipe_service_ops;
}